Mercurial > libervia-backend
comparison frontends/src/jp/base.py @ 2235:4db836386641
jp: added use_pubsub and use_pubsub_node_req arguments to CommandBase
pubsub add --node and --service arguments
pubsub_node_req add --service and a positional node argument (i.e. mandatory)
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 27 Apr 2017 01:01:43 +0200 |
parents | 1010054cf771 |
children | fd4111075e00 |
comparison
equal
deleted
inserted
replaced
2234:a41a4729c2d8 | 2235:4db836386641 |
---|---|
306 if progressbar: | 306 if progressbar: |
307 progress_parent.add_argument("-P", "--progress", action="store_true", help=_("Show progress bar")) | 307 progress_parent.add_argument("-P", "--progress", action="store_true", help=_("Show progress bar")) |
308 | 308 |
309 verbose_parent = self.parents['verbose'] = argparse.ArgumentParser(add_help=False) | 309 verbose_parent = self.parents['verbose'] = argparse.ArgumentParser(add_help=False) |
310 verbose_parent.add_argument('--verbose', '-v', action='count', default=0, help=_(u"Add a verbosity level (can be used multiple times)")) | 310 verbose_parent.add_argument('--verbose', '-v', action='count', default=0, help=_(u"Add a verbosity level (can be used multiple times)")) |
311 | |
312 for parent_name in ('pubsub', 'pubsub_node_req'): | |
313 parent = self.parents[parent_name] = argparse.ArgumentParser(add_help=False) | |
314 parent.add_argument("-s", "--service", type=unicode_decoder, default=u'', | |
315 help=_(u"JID of the PubSub service (default: PEP service)")) | |
316 if parent_name == 'pubsub_node_req': | |
317 parent.add_argument("node", type=unicode_decoder, help=_(u"node to request")) | |
318 else: | |
319 parent.add_argument("-n", "--node", type=unicode_decoder, default=u'', help=_(u"node to request")) | |
311 | 320 |
312 def add_parser_options(self): | 321 def add_parser_options(self): |
313 self.parser.add_argument('--version', action='version', version=("%(name)s %(version)s %(copyleft)s" % {'name': PROG_NAME, 'version': self.version, 'copyleft': COPYLEFT})) | 322 self.parser.add_argument('--version', action='version', version=("%(name)s %(version)s %(copyleft)s" % {'name': PROG_NAME, 'version': self.version, 'copyleft': COPYLEFT})) |
314 | 323 |
315 def register_output(self, type_, name, callback, description="", default=False): | 324 def register_output(self, type_, name, callback, description="", default=False): |
614 output_parent.add_argument('--output-option', '--oo', type=unicode_decoder, action="append", dest='output_opts', default=[], help=_(u"output specific option")) | 623 output_parent.add_argument('--output-option', '--oo', type=unicode_decoder, action="append", dest='output_opts', default=[], help=_(u"output specific option")) |
615 parents.add(output_parent) | 624 parents.add(output_parent) |
616 else: | 625 else: |
617 assert extra_outputs is None | 626 assert extra_outputs is None |
618 | 627 |
628 if 'use_pubsub' in kwargs and 'use_pubsub_node_req' in kwargs: | |
629 raise exceptions.InternalError(u"use_pubsub and use_pubsub_node_req can't be used at the same time." | |
630 u"Use the later one when node is required (else an empty string is used as default)") | |
631 | |
619 # other common options | 632 # other common options |
620 use_opts = {k:v for k,v in kwargs.iteritems() if k.startswith('use_')} | 633 use_opts = {k:v for k,v in kwargs.iteritems() if k.startswith('use_')} |
621 for param, do_use in use_opts.iteritems(): | 634 for param, do_use in use_opts.iteritems(): |
622 opt=param[4:] # if param is use_verbose, opt is verbose | 635 opt=param[4:] # if param is use_verbose, opt is verbose |
623 if opt not in self.host.parents: | 636 if opt not in self.host.parents: |