From: Brian Warner Date: Tue, 5 Dec 2006 19:35:15 +0000 (-0700) Subject: fix bin/allmydata argument-parsing X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~450 X-Git-Url: https://git.rkrishnan.org/pf/content/en/service/rgr-080307.php?a=commitdiff_plain;h=09333a1b888544146524683734b35e69fd8985f0;p=tahoe-lafs%2Ftahoe-lafs.git fix bin/allmydata argument-parsing --- diff --git a/allmydata/scripts/runner.py b/allmydata/scripts/runner.py index ceea9c51..76310ed2 100644 --- a/allmydata/scripts/runner.py +++ b/allmydata/scripts/runner.py @@ -20,13 +20,36 @@ class RestartOptions(usage.Options): class CreateClientOptions(usage.Options): optParameters = [ - ["basedir", "C", ".", "which directory to create the client in"], + ["basedir", "C", None, "which directory to create the client in"], ] + + def parseArgs(self, *args): + if len(args) > 0: + self['basedir'] = args[0] + if len(args) > 1: + raise usage.UsageError("I wasn't expecting so many arguments") + + def postOptions(self): + if self['basedir'] is None: + raise usage.UsageError(" parameter is required") + self['basedir'] = os.path.abspath(self['basedir']) + class CreateQueenOptions(usage.Options): optParameters = [ - ["basedir", "C", ".", "which directory to create the queen in"], + ["basedir", "C", None, "which directory to create the queen in"], ] + def parseArgs(self, *args): + if len(args) > 0: + self['basedir'] = args[0] + if len(args) > 1: + raise usage.UsageError("I wasn't expecting so many arguments") + + def postOptions(self): + if self['basedir'] is None: + raise usage.UsageError(" parameter is required") + self['basedir'] = os.path.abspath(self['basedir']) + client_tac = """ # -*- python -*- @@ -54,12 +77,12 @@ c.setServiceParent(application) class Options(usage.Options): synopsis = "Usage: allmydata [command options]" - subcommands = [ - ["create-client", None, CreateClientOptions], - ["create-queen", None, CreateQueenOptions], - ["start", None, StartOptions], - ["stop", None, StopOptions], - ["restart", None, RestartOptions], + subCommands = [ + ["create-client", None, CreateClientOptions, "Create a client node."], + ["create-queen", None, CreateQueenOptions, "Create a queen node."], + ["start", None, StartOptions, "Start a node (of any type)."], + ["stop", None, StopOptions, "Stop a node."], + ["restart", None, RestartOptions, "Restart a node."], ] def postOptions(self): @@ -99,7 +122,7 @@ def create_client(config): f = open(os.path.join(basedir, "client.tac"), "w") f.write(client_tac) f.close() - print "client created, please copy roster_pburl into the directory" + print "client created in %s, please copy roster_pburl into the directory" % basedir def create_queen(config): basedir = config['basedir'] @@ -107,7 +130,7 @@ def create_queen(config): f = open(os.path.join(basedir, "queen.tac"), "w") f.write(queen_tac) f.close() - print "queen created" + print "queen created in %s" % basedir def start(config): basedir = config['basedir']