mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-19 15:53:48 +00:00
bin/tahoe: clean up global-vs-subcommand arguments like --node-directory
The new rules for "bin/tahoe ARG1.. SUBCOMMAND ARG2.." arg: * --node-directory is only accepted in ARG1, not ARG2 * create-*/start/stop/restart accept --basedir in ARG2, or an explicit basedir argument * only one of --node-directory/--basedir/explicit-basedir is accepted * --quiet/--version is only accepted in ARG1, not ARG2 Closes #166
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
|
||||
import sys
|
||||
import os, sys
|
||||
from cStringIO import StringIO
|
||||
|
||||
from twisted.python import usage
|
||||
|
||||
from allmydata.scripts.common import BaseOptions
|
||||
from allmydata.scripts.common import get_default_nodedir
|
||||
from allmydata.scripts import debug, create_node, startstop_node, cli, keygen, stats_gatherer, admin
|
||||
from allmydata.util.encodingutil import quote_output, get_io_encoding
|
||||
|
||||
@ -15,7 +15,24 @@ def GROUP(s):
|
||||
return [("\n" + s, None, None, None)]
|
||||
|
||||
|
||||
class Options(BaseOptions, usage.Options):
|
||||
_default_nodedir = get_default_nodedir()
|
||||
|
||||
NODEDIR_HELP = ("Specify which Tahoe node directory should be used. The "
|
||||
"directory should either contain a full Tahoe node, or a "
|
||||
"file named node.url that points to some other Tahoe node. "
|
||||
"It should also contain a file named '"
|
||||
+ os.path.join('private', 'aliases') +
|
||||
"' which contains the mapping from alias name to root "
|
||||
"dirnode URI.")
|
||||
if _default_nodedir:
|
||||
NODEDIR_HELP += " [default for most commands: " + quote_output(_default_nodedir) + "]"
|
||||
|
||||
class Options(usage.Options):
|
||||
# unit tests can override these to point at StringIO instances
|
||||
stdin = sys.stdin
|
||||
stdout = sys.stdout
|
||||
stderr = sys.stderr
|
||||
|
||||
synopsis = "\nUsage: tahoe <command> [command options]"
|
||||
subCommands = ( GROUP("Administration")
|
||||
+ create_node.subCommands
|
||||
@ -30,6 +47,28 @@ class Options(BaseOptions, usage.Options):
|
||||
+ cli.subCommands
|
||||
)
|
||||
|
||||
optFlags = [
|
||||
["quiet", "q", "Operate silently."],
|
||||
["version", "V", "Display version numbers."],
|
||||
["version-and-path", None, "Display version numbers and paths to their locations."],
|
||||
]
|
||||
optParameters = [
|
||||
["node-directory", "d", None, NODEDIR_HELP],
|
||||
]
|
||||
|
||||
def opt_version(self):
|
||||
import allmydata
|
||||
print >>self.stdout, allmydata.get_package_versions_string(debug=True)
|
||||
self.no_command_needed = True
|
||||
|
||||
def opt_version_and_path(self):
|
||||
import allmydata
|
||||
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-options] <command> [command-options]"
|
||||
|
||||
def getUsage(self, **kwargs):
|
||||
t = usage.Options.getUsage(self, **kwargs)
|
||||
return t + "\nPlease run 'tahoe <command> --help' for more details on each command.\n"
|
||||
|
Reference in New Issue
Block a user