Mercurial > gcp
changeset 28:548dfc861531
Added 'gcp file dest_file' syntax management
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 30 Sep 2010 17:56:59 +0800 |
parents | 95f16ff36308 |
children | 52e78b0081e1 |
files | gcp |
diffstat | 1 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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: