# HG changeset patch # User Goffi # Date 1522306778 -7200 # Node ID dcc77f23e37034f7ede76e749d2af7d92165cb2c # Parent 0a22dc80d67123f0746b05c0bee35a98a1040920 jp (base): add --max option: when MULTI_ITEMS is set, --max options is automatically added, except if NO_MAX flag is set. diff -r 0a22dc80d671 -r dcc77f23e370 frontends/src/jp/base.py --- a/frontends/src/jp/base.py Thu Mar 29 08:57:27 2018 +0200 +++ b/frontends/src/jp/base.py Thu Mar 29 08:59:38 2018 +0200 @@ -353,6 +353,9 @@ elif flags.multi_items: # mutiple items pubsub_group.add_argument("-i", "--item", type=unicode_decoder, action='append', dest='items', default=[], help=_(u"items to retrieve (DEFAULT: all)")) + if not flags.no_max: + pubsub_group.add_argument("-m", "--max", type=int, default=10, + help=_(u"maximum number of items to get ({no_limit} to get all items)".format(no_limit=C.NO_LIMIT))) if flags: raise exceptions.InternalError('unknowns flags: {flags}'.format(flags=u', '.join(flags))) diff -r 0a22dc80d671 -r dcc77f23e370 frontends/src/jp/cmd_blog.py --- a/frontends/src/jp/cmd_blog.py Thu Mar 29 08:57:27 2018 +0200 +++ b/frontends/src/jp/cmd_blog.py Thu Mar 29 08:59:38 2018 +0200 @@ -168,7 +168,6 @@ self.need_loop=True def add_parser_options(self): - self.parser.add_argument("-m", "--max", type=int, default=10, help=_(u"maximum number of items to get ({} to get all items)".format(C.NO_LIMIT))) # TODO: a key(s) argument to select keys to display self.parser.add_argument("-k", "--key", type=base.unicode_decoder, action='append', dest='keys', help=_(u"microblog data key(s) to display (default: depend of verbosity)")) diff -r 0a22dc80d671 -r dcc77f23e370 frontends/src/jp/cmd_pubsub.py --- a/frontends/src/jp/cmd_pubsub.py Thu Mar 29 08:57:27 2018 +0200 +++ b/frontends/src/jp/cmd_pubsub.py Thu Mar 29 08:59:38 2018 +0200 @@ -528,7 +528,6 @@ def add_parser_options(self): self.parser.add_argument("-S", "--sub-id", type=base.unicode_decoder, default=u'', help=_(u"subscription id")) - self.parser.add_argument("-m", "--max", type=int, default=10, help=_(u"maximum number of items to get ({} to get all items)".format(C.NO_LIMIT))) # TODO: a key(s) argument to select keys to display # TODO: add MAM filters @@ -742,7 +741,7 @@ EXEC_ACTIONS = (u'exec', u'external') def __init__(self, host): - base.CommandBase.__init__(self, host, 'search', use_output=C.OUTPUT_XML, use_pubsub=True, pubsub_flags={C.MULTI_ITEMS}, + base.CommandBase.__init__(self, host, 'search', use_output=C.OUTPUT_XML, use_pubsub=True, pubsub_flags={C.MULTI_ITEMS, C.NO_MAX}, use_verbose=True, help=_(u'search items corresponding to filters')) self.need_loop=True diff -r 0a22dc80d671 -r dcc77f23e370 frontends/src/jp/constants.py --- a/frontends/src/jp/constants.py Thu Mar 29 08:57:27 2018 +0200 +++ b/frontends/src/jp/constants.py Thu Mar 29 08:59:38 2018 +0200 @@ -41,6 +41,7 @@ NODE = u'node' # node required SINGLE_ITEM = u'single_item' # only one item is allowed MULTI_ITEMS = u'multi_items' # multiple items are allowed + NO_MAX = u'no_max' # don't add --max option for multi items # ANSI A_HEADER = A.BOLD + A.FG_YELLOW