add --count option to console applications
This commit is contained in:
parent
239d19ec89
commit
0733e35cd5
1 changed files with 8 additions and 1 deletions
|
|
@ -64,6 +64,7 @@ class ConsoleApplication(BaseApplication):
|
|||
|
||||
results_options = OptionGroup(self._parser, 'Results Options')
|
||||
results_options.add_option('-c', '--condition', help='filter result items to display given a boolean condition')
|
||||
results_options.add_option('-n', '--count', type='int', help='get a maximum number of results (all backends merged)')
|
||||
results_options.add_option('-f', '--formatter', choices=formatters, help='select output formatter (%s)' % u','.join(formatters))
|
||||
results_options.add_option('-s', '--select', help='select result item keys to display (comma separated)')
|
||||
self._parser.add_option_group(results_options)
|
||||
|
|
@ -273,7 +274,9 @@ class ConsoleApplication(BaseApplication):
|
|||
"""
|
||||
Call Weboob.do(), after having filled the yielded object, if selected fields are given by user.
|
||||
"""
|
||||
for backend, result in self.weboob.do(function, *args, **kwargs):
|
||||
for i, (backend, result) in enumerate(self.weboob.do(function, *args, **kwargs)):
|
||||
if self.options.count and i == self.options.count:
|
||||
break
|
||||
fields = set(self.selected_fields) - set('*')
|
||||
if fields:
|
||||
try:
|
||||
|
|
@ -287,6 +290,8 @@ class ConsoleApplication(BaseApplication):
|
|||
Call Weboob.do_caps(), after having filled the yielded object, if selected fields are given by user.
|
||||
"""
|
||||
for backend, result in self.weboob.do_caps(caps, function, *args, **kwargs):
|
||||
if self.options.count and i == self.options.count:
|
||||
break
|
||||
fields = set(self.selected_fields) - set('*')
|
||||
if fields:
|
||||
try:
|
||||
|
|
@ -300,6 +305,8 @@ class ConsoleApplication(BaseApplication):
|
|||
Call Weboob.do_backends(), after having filled the yielded object, if selected fields are given by user.
|
||||
"""
|
||||
for backend, result in self.weboob.do_backends(backends, function, *args, **kwargs):
|
||||
if self.options.count and i == self.options.count:
|
||||
break
|
||||
fields = set(self.selected_fields) - set('*')
|
||||
if fields:
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue