mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-24 07:06:41 +00:00
scripts: rearrange Options, make --version behave the same for all commands
This commit is contained in:
parent
4ed7f0ac2a
commit
ceef80bee6
@ -1,14 +1,9 @@
|
|||||||
|
|
||||||
import os.path, sys
|
import os.path, sys
|
||||||
from twisted.python import usage
|
from twisted.python import usage
|
||||||
|
from allmydata.scripts.common import BaseOptions
|
||||||
|
|
||||||
class OptionsMixin(usage.Options):
|
class VDriveOptions(BaseOptions, usage.Options):
|
||||||
optFlags = [
|
|
||||||
["quiet", "q", "Operate silently."],
|
|
||||||
["version", "V", "Display version numbers and exit."],
|
|
||||||
]
|
|
||||||
|
|
||||||
class VDriveOptions(OptionsMixin):
|
|
||||||
optParameters = [
|
optParameters = [
|
||||||
["vdrive", "d", "global",
|
["vdrive", "d", "global",
|
||||||
"which virtual drive to use: 'global' or 'private'"],
|
"which virtual drive to use: 'global' or 'private'"],
|
||||||
@ -21,6 +16,8 @@ class ListOptions(VDriveOptions):
|
|||||||
def parseArgs(self, vdrive_filename=""):
|
def parseArgs(self, vdrive_filename=""):
|
||||||
self['vdrive_filename'] = vdrive_filename
|
self['vdrive_filename'] = vdrive_filename
|
||||||
|
|
||||||
|
longdesc = """List the contents of some portion of the virtual drive."""
|
||||||
|
|
||||||
class GetOptions(VDriveOptions):
|
class GetOptions(VDriveOptions):
|
||||||
def parseArgs(self, vdrive_filename, local_filename="-"):
|
def parseArgs(self, vdrive_filename, local_filename="-"):
|
||||||
self['vdrive_filename'] = vdrive_filename
|
self['vdrive_filename'] = vdrive_filename
|
||||||
|
@ -1,8 +1,24 @@
|
|||||||
|
|
||||||
import os
|
import os, sys
|
||||||
from twisted.python import usage
|
from twisted.python import usage
|
||||||
|
|
||||||
|
|
||||||
|
class BaseOptions:
|
||||||
|
optFlags = [
|
||||||
|
["quiet", "q", "Operate silently."],
|
||||||
|
["version", "V", "Display version numbers and exit."],
|
||||||
|
]
|
||||||
|
|
||||||
|
def opt_version(self):
|
||||||
|
from twisted import copyright
|
||||||
|
import allmydata, zfec, foolscap
|
||||||
|
print "Twisted version:", copyright.version
|
||||||
|
print "Foolscap version:", foolscap.__version__
|
||||||
|
print "zfec version:", zfec.__version__
|
||||||
|
print "allmydata version:", allmydata.__version__
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
class BasedirMixin:
|
class BasedirMixin:
|
||||||
optFlags = [
|
optFlags = [
|
||||||
["multiple", "m", "allow multiple basedirs to be specified at once"],
|
["multiple", "m", "allow multiple basedirs to be specified at once"],
|
||||||
|
@ -3,9 +3,10 @@ import sys
|
|||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
from twisted.python import usage
|
from twisted.python import usage
|
||||||
|
|
||||||
|
from allmydata.scripts.common import BaseOptions
|
||||||
import debug, create_node, startstop_node, cli
|
import debug, create_node, startstop_node, cli
|
||||||
|
|
||||||
class Options(cli.OptionsMixin):
|
class Options(BaseOptions, usage.Options):
|
||||||
synopsis = "Usage: allmydata <command> [command options]"
|
synopsis = "Usage: allmydata <command> [command options]"
|
||||||
|
|
||||||
subCommands = []
|
subCommands = []
|
||||||
@ -14,15 +15,6 @@ class Options(cli.OptionsMixin):
|
|||||||
subCommands += debug.subCommands
|
subCommands += debug.subCommands
|
||||||
subCommands += cli.subCommands
|
subCommands += cli.subCommands
|
||||||
|
|
||||||
def opt_version(self):
|
|
||||||
from twisted import copyright
|
|
||||||
import allmydata, zfec, foolscap
|
|
||||||
print "Twisted version:", copyright.version
|
|
||||||
print "Foolscap version:", foolscap.__version__
|
|
||||||
print "zfec version:", zfec.__version__
|
|
||||||
print "allmydata version:", allmydata.__version__
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
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")
|
||||||
|
Loading…
Reference in New Issue
Block a user