]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Fix and simplify argument handling for put/get (it was wrong for 'tahoe put - REMOTE').
authorDaira Hopwood <daira@jacaranda.org>
Tue, 28 Oct 2014 18:27:10 +0000 (18:27 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 27 Jan 2015 17:09:45 +0000 (17:09 +0000)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/scripts/cli.py

index b7377ead4485477cd622de04105a41f26244c226..e240c9ecd1682af1a8e1b1823884f5fe4f864578 100644 (file)
@@ -140,12 +140,11 @@ class GetOptions(FilesystemOptions):
         # tahoe get FOO bar              # write to local file
         # tahoe get tahoe:FOO bar        # same
 
-        self.from_file = argv_to_unicode(arg1)
+        if arg2 == "-":
+            arg2 = None
 
-        if arg2 and arg2 != "-":
-            self.to_file = argv_to_abspath(arg2)
-        else:
-            self.to_file = None
+        self.from_file = argv_to_unicode(arg1)
+        self.to_file   = None if arg2 is None else argv_to_abspath(arg2)
 
     def getSynopsis(self):
         return "Usage:  %s [global-opts] get [options] REMOTE_FILE LOCAL_FILE" % (self.command_name,)
@@ -180,15 +179,8 @@ class PutOptions(FilesystemOptions):
         if arg1 == "-":
             arg1 = None
 
-        if arg1 is not None and arg2 is not None:
-            self.from_file = argv_to_abspath(arg1)
-            self.to_file =  argv_to_unicode(arg2)
-        elif arg1 is not None and arg2 is None:
-            self.from_file = argv_to_abspath(arg1)
-            self.to_file = None
-        else:
-            self.from_file = None
-            self.to_file = None
+        self.from_file = None if arg1 is None else argv_to_abspath(arg1)
+        self.to_file   = None if arg2 is None else argv_to_unicode(arg2)
 
         if self['format']:
             if self['format'].upper() not in ("SDMF", "MDMF", "CHK"):