1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-26 06:46:13 +01:00

Handle conflicting options manually because the mutually exclusive group is buggy

This commit is contained in:
Daniel Mach 2022-08-26 17:10:24 +02:00
parent 3763bff901
commit a362edee5e

View File

@ -81,6 +81,16 @@ class Osc(cmdln.Cmdln):
argument_parser.add_argument(*args, **kwargs)
arguments = []
arguments.append(dict(
names=['-v', '--verbose'],
action='store_true',
help='increase verbosity',
))
arguments.append(dict(
names=['-q', '--quiet'],
action='store_true',
help='be quiet, not verbose',
))
arguments.append(dict(
names=['--debugger'],
action='store_true',
@ -130,24 +140,14 @@ class Osc(cmdln.Cmdln):
_add_parser_arguments_from_data(parser, arguments)
verbose_group = parser.add_mutually_exclusive_group()
verbose_group_arguments = []
verbose_group_arguments.append(dict(
names=['-v', '--verbose'],
action='store_true',
help='increase verbosity',
))
verbose_group_arguments.append(dict(
names=['-q', '--quiet'],
action='store_true',
help='be quiet, not verbose',
))
_add_parser_arguments_from_data(verbose_group, verbose_group_arguments)
def post_argparse(self):
"""merge commandline options into the config"""
# handle conflicting options manually because the mutually exclusive group is buggy
# https://github.com/python/cpython/issues/96310
if self.options.quiet and self.options.verbose:
self.argparse_error("argument -q/--quiet: not allowed with argument -v/--verbose")
# avoid loading config that may trigger prompt for username, password etc.
if not self.options.command:
# no command specified