changeset 2516:842bd1594077

jp (file/send): --name can now be specified
author Goffi <goffi@goffi.org>
date Wed, 14 Mar 2018 07:57:04 +0100
parents 00480cf83fa1
children cd7a53c31eb6
files frontends/src/jp/cmd_file.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/jp/cmd_file.py	Sun Mar 11 19:18:00 2018 +0100
+++ b/frontends/src/jp/cmd_file.py	Wed Mar 14 07:57:04 2018 +0100
@@ -47,6 +47,7 @@
         self.parser.add_argument("-b", "--bz2", action="store_true", help=_(u"make a bzip2 tarball"))
         self.parser.add_argument("-d", "--path", type=base.unicode_decoder, help=(u"path to the directory where the file must be stored"))
         self.parser.add_argument("-N", "--namespace", type=base.unicode_decoder, help=(u"namespace of the file"))
+        self.parser.add_argument("-n", "--name", type=base.unicode_decoder, default=u'', help=(u"name to use (DEFAULT: use source file name)"))
 
     def start(self):
         """Send files to jabber contact"""
@@ -114,11 +115,13 @@
                 bz2.close()
                 self.disp(_(u"Done !"), 1)
 
-                self.host.bridge.fileSend(self.full_dest_jid, buf.name, archive_name, '', extra, self.profile, callback=lambda pid, file_=buf.name: self.gotId(pid, file_), errback=self.error)
+                self.host.bridge.fileSend(self.full_dest_jid, buf.name, self.args.name or archive_name, '', extra, self.profile,
+                                          callback=lambda pid, file_=buf.name: self.gotId(pid, file_), errback=self.error)
         else:
             for file_ in self.args.files:
                 path = os.path.abspath(file_)
-                self.host.bridge.fileSend(self.full_dest_jid, path, '', '', extra, self.profile, callback=lambda pid, file_=file_: self.gotId(pid, file_), errback=self.error)
+                self.host.bridge.fileSend(self.full_dest_jid, path, self.args.name, '', extra, self.profile,
+                                          callback=lambda pid, file_=file_: self.gotId(pid, file_), errback=self.error)
 
 
 class Request(base.CommandBase):