From: david-sarah Date: Fri, 14 Jan 2011 03:44:14 +0000 (-0800) Subject: CLI: make 'tahoe create-alias' and 'tahoe add-alias' accept a trailing colon on the... X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/simplejson/%5B%5E?a=commitdiff_plain;h=f10a2c0902549684f85122b4529879f8f7c8c95e;p=tahoe-lafs%2Ftahoe-lafs.git CLI: make 'tahoe create-alias' and 'tahoe add-alias' accept a trailing colon on the new alias name (v2, minor change not to rely on implicit Unicode conversion). Includes doc changes and news; tests in a separate patch. fixes #1305 --- diff --git a/NEWS b/NEWS index 18f90bac..6ff38003 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ - 'top' on some Unix platforms, e.g. Linux, now shows node processes as 'tahoe' instead of 'python'. (#174) - Improve HTML formatting of the WUI. (#1219) + - The 'tahoe create-alias' and 'tahoe add-alias' commands now accept a + trailing colon on the alias. (#1305) ** Removals diff --git a/docs/frontends/CLI.rst b/docs/frontends/CLI.rst index 2026416e..4b518e18 100644 --- a/docs/frontends/CLI.rst +++ b/docs/frontends/CLI.rst @@ -247,9 +247,9 @@ access to your files and directories. Command Syntax Summary ---------------------- -``tahoe add-alias ALIAS DIRCAP`` +``tahoe add-alias ALIAS[:] DIRCAP`` -``tahoe create-alias ALIAS`` +``tahoe create-alias ALIAS[:]`` ``tahoe list-aliases`` @@ -290,7 +290,7 @@ In these summaries, ``PATH``, ``TOPATH`` or ``FROMPATH`` can be one of: Command Examples ---------------- -``tahoe add-alias ALIAS DIRCAP`` +``tahoe add-alias ALIAS[:] DIRCAP`` An example would be:: @@ -301,6 +301,9 @@ Command Examples directory. Use "``tahoe add-alias tahoe DIRCAP``" to set the contents of the default ``tahoe:`` alias. + Since Tahoe-LAFS v1.8.2, the alias name can be given with or without the + trailing colon. + ``tahoe create-alias fun`` This combines "``tahoe mkdir``" and "``tahoe add-alias``" into a single step. diff --git a/src/allmydata/scripts/cli.py b/src/allmydata/scripts/cli.py index 8a3d4180..51119c1a 100644 --- a/src/allmydata/scripts/cli.py +++ b/src/allmydata/scripts/cli.py @@ -57,19 +57,23 @@ class MakeDirectoryOptions(VDriveOptions): class AddAliasOptions(VDriveOptions): def parseArgs(self, alias, cap): self.alias = argv_to_unicode(alias) + if self.alias.endswith(u':'): + self.alias = self.alias[:-1] self.cap = cap def getSynopsis(self): - return "%s add-alias ALIAS DIRCAP" % (os.path.basename(sys.argv[0]),) + return "%s add-alias ALIAS[:] DIRCAP" % (os.path.basename(sys.argv[0]),) longdesc = """Add a new alias for an existing directory.""" class CreateAliasOptions(VDriveOptions): def parseArgs(self, alias): self.alias = argv_to_unicode(alias) + if self.alias.endswith(u':'): + self.alias = self.alias[:-1] def getSynopsis(self): - return "%s create-alias ALIAS" % (os.path.basename(sys.argv[0]),) + return "%s create-alias ALIAS[:]" % (os.path.basename(sys.argv[0]),) longdesc = """Create a new directory and add an alias for it.""" diff --git a/src/allmydata/scripts/tahoe_add_alias.py b/src/allmydata/scripts/tahoe_add_alias.py index a3ae1843..f3ed15c4 100644 --- a/src/allmydata/scripts/tahoe_add_alias.py +++ b/src/allmydata/scripts/tahoe_add_alias.py @@ -32,8 +32,13 @@ def add_alias(options): cap = options.cap stdout = options.stdout stderr = options.stderr - assert ":" not in alias - assert " " not in alias + if u":" in alias: + # a single trailing colon will already have been stripped if present + print >>stderr, "Alias names cannot contain colons." + return 1 + if u" " in alias: + print >>stderr, "Alias names cannot contain spaces." + return 1 old_aliases = get_aliases(nodedir) if alias in old_aliases: @@ -53,8 +58,13 @@ def create_alias(options): alias = options.alias stdout = options.stdout stderr = options.stderr - assert ":" not in alias - assert " " not in alias + if u":" in alias: + # a single trailing colon will already have been stripped if present + print >>stderr, "Alias names cannot contain colons." + return 1 + if u" " in alias: + print >>stderr, "Alias names cannot contain spaces." + return 1 old_aliases = get_aliases(nodedir) if alias in old_aliases: