scripts: improve rendering of synopsis/usage

Subcommands "--help" is now rendered as:

```
 tahoe [global-options] COMMAND [options] ARGS
 (use 'tahoe --help' to view global options)
 USAGE (flags/options)
 DESCRIPTION
 DESCRIPTION_UNWRAPPED
```

The new .description and .description_unwrapped fields allow
commands (subclasses of twisted.python.usage.Usage) better control over
how their explanations are rendered: the old .longdesc field was wrapped
unpleasantly.
This commit is contained in:
Brian Warner
2015-05-26 11:29:49 -07:00
parent 5d5fa05a42
commit 01619844de
2 changed files with 33 additions and 3 deletions

View File

@ -66,11 +66,15 @@ class Options(usage.Options):
print >>self.stdout, allmydata.get_package_versions_string(show_paths=True, debug=True)
self.no_command_needed = True
def getSynopsis(self):
return "\nUsage: tahoe [global-opts] <command> [command-options]"
def __str__(self):
return ("\nUsage: tahoe [global-options] <command> [command-options]\n"
+ self.getUsage())
synopsis = "\nUsage: tahoe [global-opts]" # used only for subcommands
def getUsage(self, **kwargs):
t = usage.Options.getUsage(self, **kwargs)
t = t.replace("Options:", "\nGlobal options:", 1)
return t + "\nPlease run 'tahoe <command> --help' for more details on each command.\n"
def postOptions(self):