From 91ed621ec80c2c25a629708aa774893711cfad55 Mon Sep 17 00:00:00 2001 From: bendikro Date: Tue, 26 Apr 2016 12:31:34 +0200 Subject: [PATCH] [UI] Changed ui command description and help --- deluge/ui/console/console.py | 6 +++--- deluge/ui/gtkui/gtkui.py | 5 ++--- deluge/ui/ui.py | 6 ++++-- deluge/ui/ui_entry.py | 7 +------ deluge/ui/web/web.py | 5 ++--- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/deluge/ui/console/console.py b/deluge/ui/console/console.py index d0ef89740..f782e3513 100644 --- a/deluge/ui/console/console.py +++ b/deluge/ui/console/console.py @@ -50,11 +50,10 @@ def load_commands(command_dir): class Console(UI): - help = """Starts the Deluge console interface""" - cmdline = """A console or command-line interface""" + cmd_description = """A console or command-line interface""" def __init__(self, *args, **kwargs): - super(Console, self).__init__("console", *args, **kwargs) + super(Console, self).__init__("console", *args, description="Test", **kwargs) group = self.parser.add_argument_group(_("Console Options"), "These daemon connect options will be " "used for commands, or if console ui autoconnect is enabled.") @@ -67,6 +66,7 @@ class Console(UI): # we add a subparser for each command which will trigger the help/usage when given from deluge.ui.console.main import ConsoleCommandParser # import here because (see top) self.console_parser = ConsoleCommandParser(parents=[self.parser], add_help=False, + description="Starts the Deluge console interface", formatter_class=lambda prog: DelugeTextHelpFormatter(prog, max_help_position=33, width=90)) self.parser.subparser = self.console_parser diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index aa8693d6c..3c0584832 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -136,11 +136,10 @@ DEFAULT_PREFS = { class Gtk(UI): - help = """Starts the Deluge GTK+ interface""" - cmdline = """A GTK-based graphical user interface""" + cmd_description = """A GTK-based graphical user interface""" def __init__(self, *args, **kwargs): - super(Gtk, self).__init__("gtk", *args, **kwargs) + super(Gtk, self).__init__("gtk", *args, description="Starts the Deluge GTK+ interface", **kwargs) group = self.parser.add_argument_group(_("GTK Options")) group.add_argument("torrents", metavar="", nargs="*", default=None, diff --git a/deluge/ui/ui.py b/deluge/ui/ui.py index 8bc06fe1c..ecf120b61 100644 --- a/deluge/ui/ui.py +++ b/deluge/ui/ui.py @@ -26,10 +26,12 @@ except ImportError: class UI(object): - def __init__(self, name="gtk", parser=None): + cmd_description = """Insert command description""" + + def __init__(self, name="gtk", parser=None, **kwargs): self.__name = name lang.setup_translations(setup_pygtk=(name == "gtk")) - self.__parser = parser if parser else BaseArgParser() + self.__parser = parser if parser else BaseArgParser(**kwargs) def parse_args(self, args=None): options = self.parser.parse_args(args) diff --git a/deluge/ui/ui_entry.py b/deluge/ui/ui_entry.py index c18f1f7fe..334a13c32 100644 --- a/deluge/ui/ui_entry.py +++ b/deluge/ui/ui_entry.py @@ -40,12 +40,7 @@ def start_ui(): for entrypoint in pkg_resources.iter_entry_points("deluge.ui")]) cmd_help = [_("The UI that you wish to launch. The UI choices are:")] - max_len = 0 - for k, v in ui_entrypoints.iteritems(): - cmdline = getattr(v, "cmdline", "") - max_len = max(max_len, len(cmdline)) - - cmd_help.extend(["%s -- %s" % (k, getattr(v, "cmdline", "")) for k, v in ui_entrypoints.iteritems()]) + cmd_help.extend(["%s -- %s" % (k, getattr(v, "cmd_description", "")) for k, v in ui_entrypoints.iteritems()]) group.add_argument("-u", "--ui", action="store", choices=ui_entrypoints.keys(), help="\n * ".join(cmd_help)) diff --git a/deluge/ui/web/web.py b/deluge/ui/web/web.py index c2b5312e1..c8d9399ce 100644 --- a/deluge/ui/web/web.py +++ b/deluge/ui/web/web.py @@ -28,11 +28,10 @@ class WebUI(object): class Web(UI): - help = """Starts the Deluge web interface""" - cmdline = """A web-based interface (http://localhost:8112)""" + cmd_description = """A web-based interface (http://localhost:8112)""" def __init__(self, *args, **kwargs): - super(Web, self).__init__("web", *args, **kwargs) + super(Web, self).__init__("web", *args, description="Starts the Deluge web interface", **kwargs) self.__server = None group = self.parser.add_argument_group(_("Web Server Options"))