From b94b9af1896ec527fc7812ff1e39359bdc94b182 Mon Sep 17 00:00:00 2001 From: Zooko O'Whielacronx Date: Mon, 25 Jan 2010 20:39:21 -0800 Subject: [PATCH] cli: split usage strings into groups (patch by David-Sarah Hopwood) --- src/allmydata/scripts/runner.py | 36 ++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/allmydata/scripts/runner.py b/src/allmydata/scripts/runner.py index 235cc2a0..1ac8984e 100644 --- a/src/allmydata/scripts/runner.py +++ b/src/allmydata/scripts/runner.py @@ -10,24 +10,40 @@ pkg_resources.require('allmydata-tahoe') from allmydata.scripts.common import BaseOptions import debug, create_node, startstop_node, cli, keygen, stats_gatherer -_general_commands = ( create_node.subCommands - + keygen.subCommands - + stats_gatherer.subCommands - + debug.subCommands - + cli.subCommands - ) +def group(s): + return [["\n" + s, None, None, None]] + +_commandUsage = ( group("Administration") + + create_node.subCommands + + keygen.subCommands + + stats_gatherer.subCommands + + group("Controlling a node") + + startstop_node.subCommands + + group("Debugging") + + debug.subCommands + + group("Using the filesystem") + + cli.subCommands + ) + +_subCommands = filter(lambda (a, b, c, d): not a.startswith("\n"), _commandUsage) +_synopsis = "Usage: tahoe [command options]" class Options(BaseOptions, usage.Options): - synopsis = "Usage: tahoe [command options]" + synopsis = _synopsis + subCommands = _subCommands - subCommands = [] - subCommands += _general_commands - subCommands += startstop_node.subCommands + def getUsage(self, **kwargs): + t = _Usage().getUsage(**kwargs) + return t + "\nPlease run 'tahoe --help' for more details on each command.\n" def postOptions(self): if not hasattr(self, 'subOptions'): raise usage.UsageError("must specify a command") +class _Usage(BaseOptions, usage.Options): + synopsis = _synopsis + subCommands = _commandUsage + def runner(argv, run_by_human=True, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, -- 2.45.2