comparison frontends/src/jp/base.py @ 2552:38e1e29c48e9

jp (base): added C.ITEM pubsub flag when --item is required
author Goffi <goffi@goffi.org>
date Sat, 31 Mar 2018 18:40:54 +0200
parents 1d754bc14381
children 340128e0b354
comparison
equal deleted inserted replaced
2551:b27165bf160c 2552:38e1e29c48e9
353 if default is not None: 353 if default is not None:
354 node_help += _(u" (DEFAULT: {default})".format(default=default)) 354 node_help += _(u" (DEFAULT: {default})".format(default=default))
355 pubsub_group.add_argument("-n", "--node", type=unicode_decoder, default=u'', help=node_help) 355 pubsub_group.add_argument("-n", "--node", type=unicode_decoder, default=u'', help=node_help)
356 356
357 if flags.single_item: 357 if flags.single_item:
358 pubsub_group.add_argument("-i", "--item", type=unicode_decoder, help=_(u"item to retrieve")) 358 item_help = (u"item to retrieve")
359 if not flags.item:
360 default = defaults.pop(u'item', _(u'last item'))
361 if default is not None:
362 item_help += _(u" (DEFAULT: {default})".format(default=default))
363 pubsub_group.add_argument("-i", "--item", type=unicode_decoder, help=item_help)
359 pubsub_group.add_argument("-L", "--last-item", action='store_true', help=_(u'retrieve last item')) 364 pubsub_group.add_argument("-L", "--last-item", action='store_true', help=_(u'retrieve last item'))
360 elif flags.multi_items: 365 elif flags.multi_items:
361 # mutiple items 366 # mutiple items
362 pubsub_group.add_argument("-i", "--item", type=unicode_decoder, action='append', dest='items', default=[], help=_(u"items to retrieve (DEFAULT: all)")) 367 pubsub_group.add_argument("-i", "--item", type=unicode_decoder, action='append', dest='items', default=[], help=_(u"items to retrieve (DEFAULT: all)"))
363 if not flags.no_max: 368 if not flags.no_max:
514 # because the required argument can be set in URL 519 # because the required argument can be set in URL
515 if C.SERVICE in flags and not self.args.service: 520 if C.SERVICE in flags and not self.args.service:
516 self.parser.error(_(u"argument -s/--service is required")) 521 self.parser.error(_(u"argument -s/--service is required"))
517 if C.NODE in flags and not self.args.node: 522 if C.NODE in flags and not self.args.node:
518 self.parser.error(_(u"argument -n/--node is required")) 523 self.parser.error(_(u"argument -n/--node is required"))
524 if C.ITEM in flags and not self.args.item:
525 self.parser.error(_(u"argument -i/--item is required"))
519 526
520 # FIXME: mutually groups can't be nested in a group and don't support title 527 # FIXME: mutually groups can't be nested in a group and don't support title
521 # so we check conflict here. This may be fixed in Python 3, to be checked 528 # so we check conflict here. This may be fixed in Python 3, to be checked
522 try: 529 try:
523 if self.args.item and self.args.item_last: 530 if self.args.item and self.args.item_last: