cli: split usage strings into groups (patch by David-Sarah Hopwood)
This commit is contained in:
parent
87f1bae7fe
commit
b94b9af189
|
@ -10,24 +10,40 @@ pkg_resources.require('allmydata-tahoe')
|
||||||
from allmydata.scripts.common import BaseOptions
|
from allmydata.scripts.common import BaseOptions
|
||||||
import debug, create_node, startstop_node, cli, keygen, stats_gatherer
|
import debug, create_node, startstop_node, cli, keygen, stats_gatherer
|
||||||
|
|
||||||
_general_commands = ( create_node.subCommands
|
def group(s):
|
||||||
+ keygen.subCommands
|
return [["\n" + s, None, None, None]]
|
||||||
+ stats_gatherer.subCommands
|
|
||||||
+ debug.subCommands
|
_commandUsage = ( group("Administration")
|
||||||
+ cli.subCommands
|
+ 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> [command options]"
|
||||||
|
|
||||||
class Options(BaseOptions, usage.Options):
|
class Options(BaseOptions, usage.Options):
|
||||||
synopsis = "Usage: tahoe <command> [command options]"
|
synopsis = _synopsis
|
||||||
|
subCommands = _subCommands
|
||||||
|
|
||||||
subCommands = []
|
def getUsage(self, **kwargs):
|
||||||
subCommands += _general_commands
|
t = _Usage().getUsage(**kwargs)
|
||||||
subCommands += startstop_node.subCommands
|
return t + "\nPlease run 'tahoe <command> --help' for more details on each command.\n"
|
||||||
|
|
||||||
def postOptions(self):
|
def postOptions(self):
|
||||||
if not hasattr(self, 'subOptions'):
|
if not hasattr(self, 'subOptions'):
|
||||||
raise usage.UsageError("must specify a command")
|
raise usage.UsageError("must specify a command")
|
||||||
|
|
||||||
|
class _Usage(BaseOptions, usage.Options):
|
||||||
|
synopsis = _synopsis
|
||||||
|
subCommands = _commandUsage
|
||||||
|
|
||||||
def runner(argv,
|
def runner(argv,
|
||||||
run_by_human=True,
|
run_by_human=True,
|
||||||
stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr,
|
stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr,
|
||||||
|
|
Loading…
Reference in New Issue