Index: cli.py ================================================================== --- cli.py +++ cli.py @@ -36,18 +36,21 @@ plugins = {} # only populated sparsely by .stream() # start def __init__(self, actions): - + #log.INIT(actions) + #log.CONF(conf.args) # fake init action.main = empty_parent() action.main.current_channel = self.current_channel # check if enough arguments, else help - if not actions: - a = self.help + if conf.args.version: + cmd = self.show_version + elif not actions: + cmd = self.help # first cmdline arg == action else: command = actions[0] if command in dir(self): cmd = self.__getattribute__(command) @@ -54,10 +57,11 @@ else: log.ERR("No such command:", command) return # run + #log.CONF(cmd) result = cmd(*actions[1:]) if result: self.json(result) @@ -73,11 +77,22 @@ streamtuner2 url "..." load fresh: streamtuner2 category shoutcast "Top 40" streamtuner2 categories xiph """) - + + # only show -V version + def show_version(self, *args): + print(plugin_meta(frame=3)["version"]) + + # show modules and versions + def modules(self, *args): + self.channel("pluginmanager2") + for name in ["st2", "config", "uikit", "pluginconf", "action", "cli", "ahttp"] + module_list(): + meta = plugin_meta(module=name, extra_base=["config"]) + print("%s: %s" % (name, meta["version"])) + # prints stream data from cache def stream(self, *args): # optional channel name, title if len(args) > 1: @@ -140,12 +155,12 @@ # load module def channel(self, module): plugin = __import__("channels."+module, None, None, [""]) plugin_class = plugin.__dict__[module] - p = plugin_class(None) - p.parent = empty_parent() + parent = empty_parent() + p = plugin_class(parent) return p # load all channel modules def channels(self, channels=None): if channels: @@ -163,11 +178,12 @@ # trap for some main window calls class empty_parent (object): channel = {} + hooks = { "init": [], "config_save": [], "config_load": [] } null = lambda *a: None status = lambda *a: None thread = lambda *a: None Index: st2.py ================================================================== --- st2.py +++ st2.py @@ -516,11 +516,11 @@ # startup procedure def main(): # graphical - if not len(conf.args.action): + if not len(conf.args.action) and not conf.args.version: # prepare for threading in Gtk+ callbacks gobject.threads_init() # prepare main window @@ -538,11 +538,12 @@ log.PROC(r" gtk_main_quit ") # invoke command-line interface else: import cli + #print "CLI.py:" cli.StreamTunerCLI(conf.args.action) # run if __name__ == "__main__": main()