mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-31 08:25:35 +00:00
CLI: make the --mutable-type option value for 'tahoe put' and 'tahoe mkdir' case-insensitive, and change --help for these commands accordingly. fixes #1527
This commit is contained in:
parent
64996a913d
commit
23f46b758e
@ -51,14 +51,17 @@ class VDriveOptions(BaseOptions):
|
|||||||
|
|
||||||
class MakeDirectoryOptions(VDriveOptions):
|
class MakeDirectoryOptions(VDriveOptions):
|
||||||
optParameters = [
|
optParameters = [
|
||||||
("mutable-type", None, False, "Create a mutable file in the given format. Valid formats are 'sdmf' for SDMF and 'mdmf' for MDMF"),
|
("mutable-type", None, None, "Create a mutable directory in the given format. "
|
||||||
|
"Valid formats are SDMF and MDMF, case-insensitive."),
|
||||||
]
|
]
|
||||||
|
|
||||||
def parseArgs(self, where=""):
|
def parseArgs(self, where=""):
|
||||||
self.where = argv_to_unicode(where)
|
self.where = argv_to_unicode(where)
|
||||||
|
|
||||||
if self['mutable-type'] and self['mutable-type'] not in ("sdmf", "mdmf"):
|
if self['mutable-type']:
|
||||||
raise usage.UsageError("%s is an invalid format" % self['mutable-type'])
|
if self['mutable-type'].lower() not in ("sdmf", "mdmf"):
|
||||||
|
raise usage.UsageError("%s is an invalid format" % self['mutable-type'])
|
||||||
|
self['mutable-type'] = self['mutable-type'].lower()
|
||||||
|
|
||||||
def getSynopsis(self):
|
def getSynopsis(self):
|
||||||
return "Usage: %s mkdir [options] [REMOTE_DIR]" % (self.command_name,)
|
return "Usage: %s mkdir [options] [REMOTE_DIR]" % (self.command_name,)
|
||||||
@ -172,7 +175,8 @@ class PutOptions(VDriveOptions):
|
|||||||
("mutable", "m", "Create a mutable file instead of an immutable one."),
|
("mutable", "m", "Create a mutable file instead of an immutable one."),
|
||||||
]
|
]
|
||||||
optParameters = [
|
optParameters = [
|
||||||
("mutable-type", None, False, "Create a mutable file in the given format. Valid formats are 'sdmf' for SDMF and 'mdmf' for MDMF"),
|
("mutable-type", None, None, "Create a mutable file in the given format (implies --mutable). "
|
||||||
|
"Valid formats are SDMF and MDMF, case-insensitive."),
|
||||||
]
|
]
|
||||||
|
|
||||||
def parseArgs(self, arg1=None, arg2=None):
|
def parseArgs(self, arg1=None, arg2=None):
|
||||||
@ -190,13 +194,14 @@ class PutOptions(VDriveOptions):
|
|||||||
if self.from_file == u"-":
|
if self.from_file == u"-":
|
||||||
self.from_file = None
|
self.from_file = None
|
||||||
|
|
||||||
if self['mutable-type'] and self['mutable-type'] not in ("sdmf", "mdmf"):
|
if self['mutable-type']:
|
||||||
raise usage.UsageError("%s is an invalid format" % self['mutable-type'])
|
if self['mutable-type'].lower() not in ("sdmf", "mdmf"):
|
||||||
|
raise usage.UsageError("%s is an invalid format" % self['mutable-type'])
|
||||||
|
self['mutable-type'] = self['mutable-type'].lower()
|
||||||
|
|
||||||
if self['mutable-type']:
|
if self['mutable-type']:
|
||||||
self['mutable'] = True
|
self['mutable'] = True
|
||||||
|
|
||||||
|
|
||||||
def getSynopsis(self):
|
def getSynopsis(self):
|
||||||
return "Usage: %s put [options] LOCAL_FILE REMOTE_FILE" % (self.command_name,)
|
return "Usage: %s put [options] LOCAL_FILE REMOTE_FILE" % (self.command_name,)
|
||||||
|
|
||||||
|
@ -18,10 +18,7 @@ def put(options):
|
|||||||
from_file = options.from_file
|
from_file = options.from_file
|
||||||
to_file = options.to_file
|
to_file = options.to_file
|
||||||
mutable = options['mutable']
|
mutable = options['mutable']
|
||||||
mutable_type = False
|
mutable_type = options['mutable-type']
|
||||||
|
|
||||||
if mutable:
|
|
||||||
mutable_type = options['mutable-type']
|
|
||||||
if options['quiet']:
|
if options['quiet']:
|
||||||
verbosity = 0
|
verbosity = 0
|
||||||
else:
|
else:
|
||||||
|
@ -1167,17 +1167,20 @@ class Put(GridTestMixin, CLITestMixin, unittest.TestCase):
|
|||||||
fn1 = os.path.join(self.basedir, "data")
|
fn1 = os.path.join(self.basedir, "data")
|
||||||
fileutil.write(fn1, data)
|
fileutil.write(fn1, data)
|
||||||
d = self.do_cli("create-alias", "tahoe")
|
d = self.do_cli("create-alias", "tahoe")
|
||||||
d.addCallback(lambda ignored:
|
|
||||||
self.do_cli("put", "--mutable", "--mutable-type=mdmf",
|
def _put_and_ls(ign, mutable_type, filename):
|
||||||
fn1, "tahoe:uploaded.txt"))
|
d2 = self.do_cli("put", "--mutable", "--mutable-type="+mutable_type,
|
||||||
d.addCallback(lambda ignored:
|
fn1, filename)
|
||||||
self.do_cli("ls", "--json", "tahoe:uploaded.txt"))
|
d2.addCallback(lambda ign: self.do_cli("ls", "--json", filename))
|
||||||
|
return d2
|
||||||
|
|
||||||
|
d.addCallback(_put_and_ls, "mdmf", "tahoe:uploaded.txt")
|
||||||
d.addCallback(self._check_mdmf_json)
|
d.addCallback(self._check_mdmf_json)
|
||||||
d.addCallback(lambda ignored:
|
d.addCallback(_put_and_ls, "MDMF", "tahoe:uploaded2.txt")
|
||||||
self.do_cli("put", "--mutable", "--mutable-type=sdmf",
|
d.addCallback(self._check_mdmf_json)
|
||||||
fn1, "tahoe:uploaded2.txt"))
|
d.addCallback(_put_and_ls, "sdmf", "tahoe:uploaded3.txt")
|
||||||
d.addCallback(lambda ignored:
|
d.addCallback(self._check_sdmf_json)
|
||||||
self.do_cli("ls", "--json", "tahoe:uploaded2.txt"))
|
d.addCallback(_put_and_ls, "SDMF", "tahoe:uploaded4.txt")
|
||||||
d.addCallback(self._check_sdmf_json)
|
d.addCallback(self._check_sdmf_json)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@ -3319,7 +3322,7 @@ class Mkdir(GridTestMixin, CLITestMixin, unittest.TestCase):
|
|||||||
self.do_cli("ls", "--json", self._filecap))
|
self.do_cli("ls", "--json", self._filecap))
|
||||||
d.addCallback(_check, '"mutable-type": "sdmf"')
|
d.addCallback(_check, '"mutable-type": "sdmf"')
|
||||||
d.addCallback(lambda ignored:
|
d.addCallback(lambda ignored:
|
||||||
self.do_cli("mkdir", "--mutable-type=mdmf", "tahoe:bar"))
|
self.do_cli("mkdir", "--mutable-type=MDMF", "tahoe:bar"))
|
||||||
d.addCallback(_check, "URI:DIR2-MDMF")
|
d.addCallback(_check, "URI:DIR2-MDMF")
|
||||||
d.addCallback(_stash_dircap)
|
d.addCallback(_stash_dircap)
|
||||||
d.addCallback(lambda ignored:
|
d.addCallback(lambda ignored:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user