[UI] Changed ui command description and help

This commit is contained in:
bendikro 2016-04-26 12:31:34 +02:00 committed by Calum Lind
parent 6adbd14bf8
commit 91ed621ec8
5 changed files with 12 additions and 17 deletions

View File

@ -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

View File

@ -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="<torrent>", nargs="*", default=None,

View File

@ -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)

View File

@ -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))

View File

@ -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"))