From 7ae97009fa79ea613510464cef40aa12854dfbea Mon Sep 17 00:00:00 2001 From: "Mr. Outis" Date: Sun, 28 Oct 2018 22:14:59 -0600 Subject: [PATCH] cli: Move mutual exclusion of --quiet and --verbose to the parser level (#1271) Close #1270 --- dvc/cli.py | 6 ++++-- dvc/command/base.py | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dvc/cli.py b/dvc/cli.py index a40f2eb20..972e22959 100644 --- a/dvc/cli.py +++ b/dvc/cli.py @@ -56,13 +56,15 @@ class VersionAction(argparse.Action): # pragma: no cover def parse_args(argv=None): # Common args parent_parser = argparse.ArgumentParser(add_help=False) - parent_parser.add_argument( + + log_level_group = parent_parser.add_mutually_exclusive_group() + log_level_group.add_argument( '-q', '--quiet', action='store_true', default=False, help='Be quiet.') - parent_parser.add_argument( + log_level_group.add_argument( '-v', '--verbose', action='store_true', diff --git a/dvc/command/base.py b/dvc/command/base.py index 571f99a55..2a86c058b 100644 --- a/dvc/command/base.py +++ b/dvc/command/base.py @@ -15,9 +15,10 @@ class CmdBase(object): @staticmethod def _set_loglevel(args): - if args.quiet and not args.verbose: + if args.quiet: Logger.be_quiet() - elif not args.quiet and args.verbose: + + elif args.verbose: Logger.be_verbose() def _find_root(self):