CLI: put "[global-opts]" in all command synopses

This commit is contained in:
Brian Warner
2012-06-18 10:44:39 -07:00
parent 51ddab6edb
commit 3ee950f09e
8 changed files with 40 additions and 40 deletions

View File

@ -4,7 +4,7 @@ from allmydata.scripts.common import BaseOptions
class GenerateKeypairOptions(BaseOptions): class GenerateKeypairOptions(BaseOptions):
def getSynopsis(self): def getSynopsis(self):
return "Usage: tahoe admin generate-keypair" return "Usage: tahoe [global-opts] admin generate-keypair"
def getUsage(self, width=None): def getUsage(self, width=None):
t = BaseOptions.getUsage(self, width) t = BaseOptions.getUsage(self, width)
@ -26,7 +26,7 @@ class DerivePubkeyOptions(BaseOptions):
self.privkey = privkey self.privkey = privkey
def getSynopsis(self): def getSynopsis(self):
return "Usage: tahoe admin derive-pubkey PRIVKEY" return "Usage: tahoe [global-opts] admin derive-pubkey PRIVKEY"
def getUsage(self, width=None): def getUsage(self, width=None):
t = BaseOptions.getUsage(self, width) t = BaseOptions.getUsage(self, width)
@ -57,7 +57,7 @@ class AdminCommand(BaseOptions):
if not hasattr(self, 'subOptions'): if not hasattr(self, 'subOptions'):
raise usage.UsageError("must specify a subcommand") raise usage.UsageError("must specify a subcommand")
def getSynopsis(self): def getSynopsis(self):
return "Usage: tahoe admin SUBCOMMAND" return "Usage: tahoe [global-opts] admin SUBCOMMAND"
def getUsage(self, width=None): def getUsage(self, width=None):
t = BaseOptions.getUsage(self, width) t = BaseOptions.getUsage(self, width)
t += """ t += """

View File

@ -58,7 +58,7 @@ class MakeDirectoryOptions(FilesystemOptions):
raise usage.UsageError("%s is an invalid format" % self['format']) raise usage.UsageError("%s is an invalid format" % self['format'])
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s mkdir [options] [REMOTE_DIR]" % (self.command_name,) return "Usage: %s [global-opts] mkdir [options] [REMOTE_DIR]" % (self.command_name,)
longdesc = """Create a new directory, either unlinked or as a subdirectory.""" longdesc = """Create a new directory, either unlinked or as a subdirectory."""
@ -70,7 +70,7 @@ class AddAliasOptions(FilesystemOptions):
self.cap = cap self.cap = cap
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s add-alias [options] ALIAS[:] DIRCAP" % (self.command_name,) return "Usage: %s [global-opts] add-alias [options] ALIAS[:] DIRCAP" % (self.command_name,)
longdesc = """Add a new alias for an existing directory.""" longdesc = """Add a new alias for an existing directory."""
@ -81,13 +81,13 @@ class CreateAliasOptions(FilesystemOptions):
self.alias = self.alias[:-1] self.alias = self.alias[:-1]
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s create-alias [options] ALIAS[:]" % (self.command_name,) return "Usage: %s [global-opts] create-alias [options] ALIAS[:]" % (self.command_name,)
longdesc = """Create a new directory and add an alias for it.""" longdesc = """Create a new directory and add an alias for it."""
class ListAliasesOptions(FilesystemOptions): class ListAliasesOptions(FilesystemOptions):
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s list-aliases [options]" % (self.command_name,) return "Usage: %s [global-opts] list-aliases [options]" % (self.command_name,)
longdesc = """Display a table of all configured aliases.""" longdesc = """Display a table of all configured aliases."""
@ -151,7 +151,7 @@ class GetOptions(FilesystemOptions):
self.to_file = None self.to_file = None
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s get [options] REMOTE_FILE LOCAL_FILE" % (self.command_name,) return "Usage: %s [global-opts] get [options] REMOTE_FILE LOCAL_FILE" % (self.command_name,)
longdesc = """ longdesc = """
Retrieve a file from the grid and write it to the local filesystem. If Retrieve a file from the grid and write it to the local filesystem. If
@ -197,7 +197,7 @@ class PutOptions(FilesystemOptions):
raise usage.UsageError("%s is an invalid format" % self['format']) raise usage.UsageError("%s is an invalid format" % self['format'])
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s put [options] LOCAL_FILE REMOTE_FILE" % (self.command_name,) return "Usage: %s [global-opts] put [options] LOCAL_FILE REMOTE_FILE" % (self.command_name,)
longdesc = """ longdesc = """
Put a file into the grid, copying its contents from the local filesystem. Put a file into the grid, copying its contents from the local filesystem.
@ -240,7 +240,7 @@ class CpOptions(FilesystemOptions):
self.destination = argv_to_unicode(args[-1]) self.destination = argv_to_unicode(args[-1])
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s cp [options] FROM.. TO" % (self.command_name,) return "Usage: %s [global-opts] cp [options] FROM.. TO" % (self.command_name,)
longdesc = """ longdesc = """
Use 'tahoe cp' to copy files between a local filesystem and a Tahoe grid. Use 'tahoe cp' to copy files between a local filesystem and a Tahoe grid.
@ -272,11 +272,11 @@ class UnlinkOptions(FilesystemOptions):
self.where = argv_to_unicode(where) self.where = argv_to_unicode(where)
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s unlink [options] REMOTE_FILE" % (self.command_name,) return "Usage: %s [global-opts] unlink [options] REMOTE_FILE" % (self.command_name,)
class RmOptions(UnlinkOptions): class RmOptions(UnlinkOptions):
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s rm [options] REMOTE_FILE" % (self.command_name,) return "Usage: %s [global-opts] rm [options] REMOTE_FILE" % (self.command_name,)
class MvOptions(FilesystemOptions): class MvOptions(FilesystemOptions):
def parseArgs(self, frompath, topath): def parseArgs(self, frompath, topath):
@ -284,7 +284,7 @@ class MvOptions(FilesystemOptions):
self.to_file = argv_to_unicode(topath) self.to_file = argv_to_unicode(topath)
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s mv [options] FROM TO" % (self.command_name,) return "Usage: %s [global-opts] mv [options] FROM TO" % (self.command_name,)
longdesc = """ longdesc = """
Use 'tahoe mv' to move files that are already on the grid elsewhere on Use 'tahoe mv' to move files that are already on the grid elsewhere on
@ -304,7 +304,7 @@ class LnOptions(FilesystemOptions):
self.to_file = argv_to_unicode(topath) self.to_file = argv_to_unicode(topath)
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s ln [options] FROM_LINK TO_LINK" % (self.command_name,) return "Usage: %s [global-opts] ln [options] FROM_LINK TO_LINK" % (self.command_name,)
longdesc = """ longdesc = """
Use 'tahoe ln' to duplicate a link (directory entry) already on the grid Use 'tahoe ln' to duplicate a link (directory entry) already on the grid
@ -351,7 +351,7 @@ class BackupOptions(FilesystemOptions):
self.to_dir = argv_to_unicode(topath) self.to_dir = argv_to_unicode(topath)
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s backup [options] FROM ALIAS:TO" % (self.command_name,) return "Usage: %s [global-opts] backup [options] FROM ALIAS:TO" % (self.command_name,)
def opt_exclude(self, pattern): def opt_exclude(self, pattern):
"""Ignore files matching a glob pattern. You may give multiple """Ignore files matching a glob pattern. You may give multiple
@ -409,7 +409,7 @@ class WebopenOptions(FilesystemOptions):
self.where = argv_to_unicode(where) self.where = argv_to_unicode(where)
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s webopen [options] [ALIAS:PATH]" % (self.command_name,) return "Usage: %s [global-opts] webopen [options] [ALIAS:PATH]" % (self.command_name,)
longdesc = """Open a web browser to the contents of some file or longdesc = """Open a web browser to the contents of some file or
directory on the grid. When run without arguments, open the Welcome directory on the grid. When run without arguments, open the Welcome
@ -426,7 +426,7 @@ class ManifestOptions(FilesystemOptions):
self.where = argv_to_unicode(where) self.where = argv_to_unicode(where)
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s manifest [options] [ALIAS:PATH]" % (self.command_name,) return "Usage: %s [global-opts] manifest [options] [ALIAS:PATH]" % (self.command_name,)
longdesc = """Print a list of all files and directories reachable from longdesc = """Print a list of all files and directories reachable from
the given starting point.""" the given starting point."""
@ -439,7 +439,7 @@ class StatsOptions(FilesystemOptions):
self.where = argv_to_unicode(where) self.where = argv_to_unicode(where)
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s stats [options] [ALIAS:PATH]" % (self.command_name,) return "Usage: %s [global-opts] stats [options] [ALIAS:PATH]" % (self.command_name,)
longdesc = """Print statistics about of all files and directories longdesc = """Print statistics about of all files and directories
reachable from the given starting point.""" reachable from the given starting point."""
@ -455,7 +455,7 @@ class CheckOptions(FilesystemOptions):
self.where = argv_to_unicode(where) self.where = argv_to_unicode(where)
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s check [options] [ALIAS:PATH]" % (self.command_name,) return "Usage: %s [global-opts] check [options] [ALIAS:PATH]" % (self.command_name,)
longdesc = """ longdesc = """
Check a single file or directory: count how many shares are available and Check a single file or directory: count how many shares are available and
@ -474,7 +474,7 @@ class DeepCheckOptions(FilesystemOptions):
self.where = argv_to_unicode(where) self.where = argv_to_unicode(where)
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s deep-check [options] [ALIAS:PATH]" % (self.command_name,) return "Usage: %s [global-opts] deep-check [options] [ALIAS:PATH]" % (self.command_name,)
longdesc = """ longdesc = """
Check all files and directories reachable from the given starting point Check all files and directories reachable from the given starting point

View File

@ -17,7 +17,7 @@ class CreateClientOptions(BasedirOptions):
] ]
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s create-client [options] [NODEDIR]" % (self.command_name,) return "Usage: %s [global-opts] create-client [options] [NODEDIR]" % (self.command_name,)
class CreateNodeOptions(CreateClientOptions): class CreateNodeOptions(CreateClientOptions):
@ -26,14 +26,14 @@ class CreateNodeOptions(CreateClientOptions):
] ]
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s create-node [options] [NODEDIR]" % (self.command_name,) return "Usage: %s [global-opts] create-node [options] [NODEDIR]" % (self.command_name,)
class CreateIntroducerOptions(BasedirOptions): class CreateIntroducerOptions(BasedirOptions):
default_nodedir = None default_nodedir = None
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s create-introducer [options] NODEDIR" % (self.command_name,) return "Usage: %s [global-opts] create-introducer [options] NODEDIR" % (self.command_name,)
client_tac = """ client_tac = """

View File

@ -11,7 +11,7 @@ from allmydata.scripts.common import BaseOptions
class DumpOptions(BaseOptions): class DumpOptions(BaseOptions):
def getSynopsis(self): def getSynopsis(self):
return "Usage: tahoe debug dump-share SHARE_FILENAME" return "Usage: tahoe [global-opts] debug dump-share SHARE_FILENAME"
optFlags = [ optFlags = [
["offsets", None, "Display a table of section offsets."], ["offsets", None, "Display a table of section offsets."],
@ -408,7 +408,7 @@ def dump_MDMF_share(m, length, options):
class DumpCapOptions(BaseOptions): class DumpCapOptions(BaseOptions):
def getSynopsis(self): def getSynopsis(self):
return "Usage: tahoe debug dump-cap [options] FILECAP" return "Usage: tahoe [global-opts] debug dump-cap [options] FILECAP"
optParameters = [ optParameters = [
["nodeid", "n", ["nodeid", "n",
None, "Specify the storage server nodeid (ASCII), to construct WE and secrets."], None, "Specify the storage server nodeid (ASCII), to construct WE and secrets."],
@ -610,7 +610,7 @@ def dump_uri_instance(u, nodeid, secret, out, show_header=True):
class FindSharesOptions(BaseOptions): class FindSharesOptions(BaseOptions):
def getSynopsis(self): def getSynopsis(self):
return "Usage: tahoe debug find-shares STORAGE_INDEX NODEDIRS.." return "Usage: tahoe [global-opts] debug find-shares STORAGE_INDEX NODEDIRS.."
def parseArgs(self, storage_index_s, *nodedirs): def parseArgs(self, storage_index_s, *nodedirs):
from allmydata.util.encodingutil import argv_to_abspath from allmydata.util.encodingutil import argv_to_abspath
@ -669,7 +669,7 @@ class CatalogSharesOptions(BaseOptions):
raise usage.UsageError("must specify at least one node directory") raise usage.UsageError("must specify at least one node directory")
def getSynopsis(self): def getSynopsis(self):
return "Usage: tahoe debug catalog-shares NODEDIRS.." return "Usage: tahoe [global-opts] debug catalog-shares NODEDIRS.."
def getUsage(self, width=None): def getUsage(self, width=None):
t = BaseOptions.getUsage(self, width) t = BaseOptions.getUsage(self, width)
@ -882,7 +882,7 @@ def catalog_shares_one_abbrevdir(si_s, si_dir, now, out, err):
class CorruptShareOptions(BaseOptions): class CorruptShareOptions(BaseOptions):
def getSynopsis(self): def getSynopsis(self):
return "Usage: tahoe debug corrupt-share SHARE_FILENAME" return "Usage: tahoe [global-opts] debug corrupt-share SHARE_FILENAME"
optParameters = [ optParameters = [
["offset", "o", "block-random", "Specify which bit to flip."], ["offset", "o", "block-random", "Specify which bit to flip."],
@ -962,7 +962,7 @@ def corrupt_share(options):
class ReplOptions(BaseOptions): class ReplOptions(BaseOptions):
def getSynopsis(self): def getSynopsis(self):
return "Usage: tahoe debug repl" return "Usage: tahoe [global-opts] debug repl"
def repl(options): def repl(options):
import code import code
@ -973,7 +973,7 @@ DEFAULT_TESTSUITE = 'allmydata'
class TrialOptions(twisted_trial.Options): class TrialOptions(twisted_trial.Options):
def getSynopsis(self): def getSynopsis(self):
return "Usage: tahoe debug trial [options] [[file|package|module|TestCase|testmethod]...]" return "Usage: tahoe [global-opts] debug trial [options] [[file|package|module|TestCase|testmethod]...]"
def parseOptions(self, all_subargs, *a, **kw): def parseOptions(self, all_subargs, *a, **kw):
self.trial_args = list(all_subargs) self.trial_args = list(all_subargs)
@ -1006,9 +1006,9 @@ def fixOptionsClass( (subcmd, shortcut, OptionsClass, desc) ):
t = OptionsClass.getSynopsis(self) t = OptionsClass.getSynopsis(self)
i = t.find("Usage: flogtool ") i = t.find("Usage: flogtool ")
if i >= 0: if i >= 0:
return "Usage: tahoe debug flogtool " + t[i+len("Usage: flogtool "):] return "Usage: tahoe [global-opts] debug flogtool " + t[i+len("Usage: flogtool "):]
else: else:
return "Usage: tahoe debug flogtool %s [options]" % (subcmd,) return "Usage: tahoe [global-opts] debug flogtool %s [options]" % (subcmd,)
return (subcmd, shortcut, FixedOptionsClass, desc) return (subcmd, shortcut, FixedOptionsClass, desc)
class FlogtoolOptions(foolscap_cli.Options): class FlogtoolOptions(foolscap_cli.Options):
@ -1017,7 +1017,7 @@ class FlogtoolOptions(foolscap_cli.Options):
self.subCommands = map(fixOptionsClass, self.subCommands) self.subCommands = map(fixOptionsClass, self.subCommands)
def getSynopsis(self): def getSynopsis(self):
return "Usage: tahoe debug flogtool (%s) [command options]" % ("|".join([x[0] for x in self.subCommands])) return "Usage: tahoe [global-opts] debug flogtool (%s) [command options]" % ("|".join([x[0] for x in self.subCommands]))
def parseOptions(self, all_subargs, *a, **kw): def parseOptions(self, all_subargs, *a, **kw):
self.flogtool_args = list(all_subargs) self.flogtool_args = list(all_subargs)

View File

@ -8,7 +8,7 @@ class CreateKeyGeneratorOptions(BasedirOptions):
default_nodedir = None default_nodedir = None
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s create-key-generator [options] NODEDIR" % (self.command_name,) return "Usage: %s [global-opts] create-key-generator [options] NODEDIR" % (self.command_name,)
keygen_tac = """ keygen_tac = """

View File

@ -67,7 +67,7 @@ class Options(usage.Options):
self.no_command_needed = True self.no_command_needed = True
def getSynopsis(self): def getSynopsis(self):
return "\nUsage: tahoe [global-options] <command> [command-options]" return "\nUsage: tahoe [global-opts] <command> [command-options]"
def getUsage(self, **kwargs): def getUsage(self, **kwargs):
t = usage.Options.getUsage(self, **kwargs) t = usage.Options.getUsage(self, **kwargs)

View File

@ -13,12 +13,12 @@ class StartOptions(BasedirOptions):
] ]
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s start [options] [NODEDIR]" % (self.command_name,) return "Usage: %s [global-opts] start [options] [NODEDIR]" % (self.command_name,)
class StopOptions(BasedirOptions): class StopOptions(BasedirOptions):
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s stop [options] [NODEDIR]" % (self.command_name,) return "Usage: %s [global-opts] stop [options] [NODEDIR]" % (self.command_name,)
class RestartOptions(BasedirOptions): class RestartOptions(BasedirOptions):
@ -28,14 +28,14 @@ class RestartOptions(BasedirOptions):
] ]
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s restart [options] [NODEDIR]" % (self.command_name,) return "Usage: %s [global-opts] restart [options] [NODEDIR]" % (self.command_name,)
class RunOptions(BasedirOptions): class RunOptions(BasedirOptions):
default_nodedir = u"." default_nodedir = u"."
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s run [options] [NODEDIR]" % (self.command_name,) return "Usage: %s [global-opts] run [options] [NODEDIR]" % (self.command_name,)
def start(opts, out=sys.stdout, err=sys.stderr): def start(opts, out=sys.stdout, err=sys.stderr):

View File

@ -8,7 +8,7 @@ class CreateStatsGathererOptions(BasedirOptions):
default_nodedir = None default_nodedir = None
def getSynopsis(self): def getSynopsis(self):
return "Usage: %s create-stats-gatherer [options] NODEDIR" % (self.command_name,) return "Usage: %s [global-opts] create-stats-gatherer [options] NODEDIR" % (self.command_name,)
stats_gatherer_tac = """ stats_gatherer_tac = """