diff options
author | Michał Górny <mgorny@gentoo.org> | 2023-04-07 15:26:21 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2023-04-07 15:28:20 +0200 |
commit | 90ddc32d97838d024bd60ceec8f30f04b42aa7f3 (patch) | |
tree | d616d69c4fcd6018b5f6f0d3dbaaea5c9f709a7a | |
parent | 019180d848b162ebe3e815f0cfe7973fcec75251 (diff) | |
download | gemato-90ddc32d97838d024bd60ceec8f30f04b42aa7f3.tar.gz |
log: Make last of --debug/--quiet take precedence
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r-- | gemato/cli.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/gemato/cli.py b/gemato/cli.py index 0047a5d..7c67a35 100644 --- a/gemato/cli.py +++ b/gemato/cli.py @@ -59,20 +59,20 @@ class GematoCommand: """ Add options specific to the command to subparser @subp. """ - subp.add_argument('--debug', action='store_true', + subp.add_argument("--debug", action="store_const", + dest="log_level", const=logging.DEBUG, + default=logging.INFO, help='Enable debugging output') - subp.add_argument('-q', '--quiet', action='store_true', - help='Only emit warning or error messages') + subp.add_argument("-q", "--quiet", action="store_const", + dest="log_level", const=logging.WARNING, + help="Only emit warning or error messages") def parse_args(self, args, argp): """ Process command-line arguments @args. @argp is the argparse instance provided for error reporting. """ - if args.debug: - logging.getLogger().setLevel(logging.DEBUG) - elif args.quiet: - logging.getLogger().setLevel(logging.WARNING) + logging.getLogger().setLevel(args.log_level) def __call__(self): """ @@ -115,7 +115,7 @@ class BaseOpenPGPMixin: env_class = OpenPGPEnvironment else: env_class = OpenPGPSystemEnvironment - self.openpgp_env = env_class(debug=args.debug, + self.openpgp_env = env_class(debug=args.log_level == logging.DEBUG, proxy=args.proxy) if args.openpgp_key is not None: |