Mercurial > libervia-backend
comparison frontends/src/jp/base.py @ 1600:8d41cd4da2f6
jp: added a --verbose command
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 14 Nov 2015 19:54:27 +0100 |
parents | 313f2bb7841b |
children | 9ac78437000d |
comparison
equal
deleted
inserted
replaced
1599:e2ed8009e66e | 1600:8d41cd4da2f6 |
---|---|
127 | 127 |
128 progress_parent = self.parents['progress'] = argparse.ArgumentParser(add_help=False) | 128 progress_parent = self.parents['progress'] = argparse.ArgumentParser(add_help=False) |
129 if progressbar: | 129 if progressbar: |
130 progress_parent.add_argument("-P", "--progress", action="store_true", help=_("Show progress bar")) | 130 progress_parent.add_argument("-P", "--progress", action="store_true", help=_("Show progress bar")) |
131 | 131 |
132 verbose_parent = self.parents['verbose'] = argparse.ArgumentParser(add_help=False) | |
133 verbose_parent.add_argument('--verbose', '-v', action='count', help=_(u"Add a verbosity level (can be used multiple times)")) | |
134 | |
132 def add_parser_options(self): | 135 def add_parser_options(self): |
133 self.parser.add_argument('--version', action='version', version=("%(name)s %(version)s %(copyleft)s" % {'name': prog_name, 'version': self.version, 'copyleft': copyleft})) | 136 self.parser.add_argument('--version', action='version', version=("%(name)s %(version)s %(copyleft)s" % {'name': prog_name, 'version': self.version, 'copyleft': copyleft})) |
134 | 137 |
135 def import_commands(self): | 138 def import_commands(self): |
136 """ Automaticaly import commands to jp | 139 """ Automaticaly import commands to jp |
330 return True | 333 return True |
331 | 334 |
332 | 335 |
333 class CommandBase(object): | 336 class CommandBase(object): |
334 | 337 |
335 def __init__(self, host, name, use_profile=True, use_progress=False, need_connect=None, help=None, **kwargs): | 338 def __init__(self, host, name, use_profile=True, use_progress=False, use_verbose=False, need_connect=None, help=None, **kwargs): |
336 """ Initialise CommandBase | 339 """ Initialise CommandBase |
337 @param host: Jp instance | 340 @param host: Jp instance |
338 @param name(unicode): name of the new command | 341 @param name(unicode): name of the new command |
339 @param use_profile(bool): if True, add profile selection/connection commands | 342 @param use_profile(bool): if True, add profile selection/connection commands |
340 @param use_progress(bool): if True, add progress bar activation commands | 343 @param use_progress(bool): if True, add progress bar activation commands |
344 @param use_verbose(bool): if True, add verbosity command | |
341 @param need_connect(bool, None): True if profile connection is needed | 345 @param need_connect(bool, None): True if profile connection is needed |
342 False else (profile session must still be started) | 346 False else (profile session must still be started) |
343 None to set auto value (i.e. True if use_profile is set) | 347 None to set auto value (i.e. True if use_profile is set) |
344 Can't be set if use_profile is False | 348 Can't be set if use_profile is False |
345 @param help(unicode): help message to display | 349 @param help(unicode): help message to display |
360 else: | 364 else: |
361 assert need_connect is None | 365 assert need_connect is None |
362 | 366 |
363 if use_progress: | 367 if use_progress: |
364 parents.add(self.host.parents['progress']) | 368 parents.add(self.host.parents['progress']) |
369 | |
370 if use_verbose: | |
371 parents.add(self.host.parents['verbose']) | |
365 | 372 |
366 self.parser = host.subparsers.add_parser(name, help=help, **kwargs) | 373 self.parser = host.subparsers.add_parser(name, help=help, **kwargs) |
367 if hasattr(self, "subcommands"): | 374 if hasattr(self, "subcommands"): |
368 self.subparsers = self.parser.add_subparsers() | 375 self.subparsers = self.parser.add_subparsers() |
369 else: | 376 else: |