]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
scripts: rearrange Options, make --version behave the same for all commands
authorBrian Warner <warner@allmydata.com>
Thu, 16 Aug 2007 19:50:19 +0000 (12:50 -0700)
committerBrian Warner <warner@allmydata.com>
Thu, 16 Aug 2007 19:50:19 +0000 (12:50 -0700)
src/allmydata/scripts/cli.py
src/allmydata/scripts/common.py
src/allmydata/scripts/runner.py

index ef14a2f557590975730bb65eb7ded0210a7b9b79..c954f9a321ff16a4c25cc2b0e3f356aef1b6dfa7 100644 (file)
@@ -1,14 +1,9 @@
 
 import os.path, sys
 from twisted.python import usage
+from allmydata.scripts.common import BaseOptions
 
-class OptionsMixin(usage.Options):
-    optFlags = [
-        ["quiet", "q", "Operate silently."],
-        ["version", "V", "Display version numbers and exit."],
-        ]
-
-class VDriveOptions(OptionsMixin):
+class VDriveOptions(BaseOptions, usage.Options):
     optParameters = [
         ["vdrive", "d", "global",
          "which virtual drive to use: 'global' or 'private'"],
@@ -21,6 +16,8 @@ class ListOptions(VDriveOptions):
     def parseArgs(self, vdrive_filename=""):
         self['vdrive_filename'] = vdrive_filename
 
+    longdesc = """List the contents of some portion of the virtual drive."""
+
 class GetOptions(VDriveOptions):
     def parseArgs(self, vdrive_filename, local_filename="-"):
         self['vdrive_filename'] = vdrive_filename
index 114022be7a0faa13c15d5f53337c49f6bb326a8b..f51e886a4455f40ac95afd92e539c2c4e73a091f 100644 (file)
@@ -1,8 +1,24 @@
 
-import os
+import os, sys
 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:
     optFlags = [
         ["multiple", "m", "allow multiple basedirs to be specified at once"],
index ad2f8fa4755dbe48550f7ad9081b0955dba992c1..72935fa759009ead6cdd2d8673c17d130ded2edd 100644 (file)
@@ -3,9 +3,10 @@ import sys
 from cStringIO import StringIO
 from twisted.python import usage
 
+from allmydata.scripts.common import BaseOptions
 import debug, create_node, startstop_node, cli
 
-class Options(cli.OptionsMixin):
+class Options(BaseOptions, usage.Options):
     synopsis = "Usage:  allmydata <command> [command options]"
 
     subCommands = []
@@ -14,15 +15,6 @@ class Options(cli.OptionsMixin):
     subCommands += debug.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):
         if not hasattr(self, 'subOptions'):
             raise usage.UsageError("must specify a command")