# HG changeset patch # User Goffi # Date 1285840619 -28800 # Node ID 548dfc8615314ecba7de01b85dc04059cbb4fa71 # Parent 95f16ff363086578db87e02243a0b87ae22097ee Added 'gcp file dest_file' syntax management diff -r 95f16ff36308 -r 548dfc861531 gcp --- a/gcp Thu Sep 30 16:44:52 2010 +0800 +++ b/gcp Thu Sep 30 17:56:59 2010 +0800 @@ -305,7 +305,7 @@ source_fd = open(source_file, 'rb') filename = os.path.basename(source_file) assert(filename) - dest_file = self.__filename_fix(os.path.join(dest_path,filename),options) + dest_file = self.__filename_fix(options.dest_file,options) if options.dest_file else self.__filename_fix(os.path.join(dest_path,filename),options) if os.path.exists(dest_file) and not options.force: warning (_("File [%s] already exists, skipping it !") % dest_file.decode('utf-8','replace')) self.journal.copyFailed() @@ -523,7 +523,8 @@ @return: a tuple (boolean, message) where the boolean is the success of the arguments validation, and message is the error message to print when necessary""" _usage=""" - %prog [options] FILE1 [FILE2 ...] DEST + %prog [options] FILE DEST + %prog [options] FILE1 [FILE2 ...] DEST-DIR %prog --help for options list """ @@ -599,6 +600,16 @@ options.preserve = preserve self.__sourcesSaving(options, args) + + if len(args) == 2: + dest_path = os.path.abspath(os.path.expanduser(args[1])) + if not os.path.exists(dest_path) or os.path.isfile(dest_path): + options.dest_file = dest_path + args[1] = os.path.dirname(dest_path) + else: + options.dest_file = None + else: + options.dest_file = None #if there is an other instance of gcp, we send options to it if not self._main_instance: