Add --quiet option.
This is need, e.g., to suppress logging message for 'exists'.
TBR=agable@chromium.org,hinoka@chromium.org
BUG=
Review URL: https://codereview.chromium.org/299163002
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@272450 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cache.py b/git_cache.py
index 4b9c1d8..957ae95 100755
--- a/git_cache.py
+++ b/git_cache.py
@@ -496,11 +496,18 @@
optparse.OptionParser.__init__(self, *args, prog='git cache', **kwargs)
self.add_option('-c', '--cache-dir',
help='Path to the directory containing the cache')
- self.add_option('-v', '--verbose', action='count', default=0,
+ self.add_option('-v', '--verbose', action='count', default=1,
help='Increase verbosity (can be passed multiple times)')
+ self.add_option('-q', '--quiet', action='store_true',
+ help='Suppress all extraneous output')
def parse_args(self, args=None, values=None):
options, args = optparse.OptionParser.parse_args(self, args, values)
+ if options.quiet:
+ options.verbose = 0
+
+ levels = [logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG]
+ logging.basicConfig(level=levels[min(options.verbose, len(levels) - 1)])
try:
global_cache_dir = Mirror.GetCachePath()
@@ -513,9 +520,6 @@
logging.warn('Overriding globally-configured cache directory.')
Mirror.SetCachePath(options.cache_dir)
- levels = [logging.WARNING, logging.INFO, logging.DEBUG]
- logging.basicConfig(level=levels[min(options.verbose, len(levels) - 1)])
-
return options, args