changeset 2545:2df1ca79cb30

jp (merge-request/import): added import command
author Goffi <goffi@goffi.org>
date Fri, 30 Mar 2018 17:53:57 +0200 (2018-03-30)
parents a64887289931
children 48820e4a1f8a
files frontends/src/jp/cmd_merge_request.py
diffstat 1 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/jp/cmd_merge_request.py	Fri Mar 30 17:53:11 2018 +0200
+++ b/frontends/src/jp/cmd_merge_request.py	Fri Mar 30 17:53:57 2018 +0200
@@ -99,8 +99,37 @@
                             exit_code=C.EXIT_BRIDGE_ERRBACK))
 
 
+
+class Import(base.CommandBase):
+
+    def __init__(self, host):
+        base.CommandBase.__init__(self, host, 'import', use_pubsub=True, pubsub_flags={C.SINGLE_ITEM}, help=_(u'import a merge request'))
+        self.need_loop=True
+
+    def add_parser_options(self):
+        self.parser.add_argument("-r", "--repository", metavar="PATH", type=base.unicode_decoder, default=u'.', help=_(u"path of the repository (DEFAULT: current directory)"))
+
+    def mergeRequestImportCb(self):
+        self.host.quit(C.EXIT_OK)
+
+    def start(self):
+        repository = os.path.expanduser(os.path.abspath(self.args.repository))
+        extra = {}
+        self.host.bridge.mergeRequestsImport(
+            repository,
+            self.args.item,
+            self.args.service,
+            self.args.node,
+            extra,
+            self.profile,
+            callback=self.mergeRequestImportCb,
+            errback=partial(self.errback,
+                            msg=_(u"can't import merge request: {}"),
+                            exit_code=C.EXIT_BRIDGE_ERRBACK))
+
+
 class MergeRequest(base.CommandBase):
-    subcommands = (Set, Get)
+    subcommands = (Set, Get, Import)
 
     def __init__(self, host):
         super(MergeRequest, self).__init__(host, 'merge-request', use_profile=False, help=_('merge-request management'))