Merge PR400: add "tahoe list-aliases --readonly-uri"

Closes tahoe-lafs/tahoe-lafs:400
This commit is contained in:
Brian Warner 2017-02-21 10:09:31 -08:00
commit bb782b0331
2 changed files with 7 additions and 1 deletions

View File

@ -82,6 +82,9 @@ class CreateAliasOptions(FilesystemOptions):
class ListAliasesOptions(FilesystemOptions):
synopsis = "[options]"
description = """Display a table of all configured aliases."""
optFlags = [
("readonly-uri", None, "Show read-only dircaps instead of readwrite"),
]
class ListOptions(FilesystemOptions):
optFlags = [

View File

@ -105,8 +105,11 @@ def list_aliases(options):
fmt = "%" + str(max_width) + "s: %s"
rc = 0
for name in alias_names:
dircap = uri.from_string(aliases[name])
if options['readonly-uri']:
dircap = dircap.get_readonly()
try:
print >>stdout, fmt % (unicode_to_output(name), unicode_to_output(aliases[name].decode('utf-8')))
print >>stdout, fmt % (unicode_to_output(name), unicode_to_output(dircap.to_string().decode('utf-8')))
except (UnicodeEncodeError, UnicodeDecodeError):
print >>stderr, fmt % (quote_output(name), quote_output(aliases[name]))
rc = 1