Mercurial > libervia-backend
changeset 2539:dcc77f23e370
jp (base): add --max option:
when MULTI_ITEMS is set, --max options is automatically added, except if NO_MAX flag is set.
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 29 Mar 2018 08:59:38 +0200 |
parents | 0a22dc80d671 |
children | 3e03de7691ce |
files | frontends/src/jp/base.py frontends/src/jp/cmd_blog.py frontends/src/jp/cmd_pubsub.py frontends/src/jp/constants.py |
diffstat | 4 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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)))
--- 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)"))
--- 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
--- 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