jp: added a --verbose command
This commit is contained in:
parent
fbbb081425
commit
891a4c33af
1 changed files with 8 additions and 1 deletions
|
|
@ -129,6 +129,9 @@ class Jp(object):
|
|||
if progressbar:
|
||||
progress_parent.add_argument("-P", "--progress", action="store_true", help=_("Show progress bar"))
|
||||
|
||||
verbose_parent = self.parents['verbose'] = argparse.ArgumentParser(add_help=False)
|
||||
verbose_parent.add_argument('--verbose', '-v', action='count', help=_(u"Add a verbosity level (can be used multiple times)"))
|
||||
|
||||
def add_parser_options(self):
|
||||
self.parser.add_argument('--version', action='version', version=("%(name)s %(version)s %(copyleft)s" % {'name': prog_name, 'version': self.version, 'copyleft': copyleft}))
|
||||
|
||||
|
|
@ -332,12 +335,13 @@ class Jp(object):
|
|||
|
||||
class CommandBase(object):
|
||||
|
||||
def __init__(self, host, name, use_profile=True, use_progress=False, need_connect=None, help=None, **kwargs):
|
||||
def __init__(self, host, name, use_profile=True, use_progress=False, use_verbose=False, need_connect=None, help=None, **kwargs):
|
||||
""" Initialise CommandBase
|
||||
@param host: Jp instance
|
||||
@param name(unicode): name of the new command
|
||||
@param use_profile(bool): if True, add profile selection/connection commands
|
||||
@param use_progress(bool): if True, add progress bar activation commands
|
||||
@param use_verbose(bool): if True, add verbosity command
|
||||
@param need_connect(bool, None): True if profile connection is needed
|
||||
False else (profile session must still be started)
|
||||
None to set auto value (i.e. True if use_profile is set)
|
||||
|
|
@ -363,6 +367,9 @@ class CommandBase(object):
|
|||
if use_progress:
|
||||
parents.add(self.host.parents['progress'])
|
||||
|
||||
if use_verbose:
|
||||
parents.add(self.host.parents['verbose'])
|
||||
|
||||
self.parser = host.subparsers.add_parser(name, help=help, **kwargs)
|
||||
if hasattr(self, "subcommands"):
|
||||
self.subparsers = self.parser.add_subparsers()
|
||||
|
|
|
|||
Loading…
Reference in a new issue