changeset 1600:8d41cd4da2f6

jp: added a --verbose command
author Goffi <goffi@goffi.org>
date Sat, 14 Nov 2015 19:54:27 +0100
parents e2ed8009e66e
children e0a152f2cf6d
files frontends/src/jp/base.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/jp/base.py	Sat Nov 14 19:21:56 2015 +0100
+++ b/frontends/src/jp/base.py	Sat Nov 14 19:54:27 2015 +0100
@@ -129,6 +129,9 @@
         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 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 @@
         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()