mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-04 18:46:17 +01:00
Handle conflicting options manually because the mutually exclusive group is buggy
This commit is contained in:
parent
3763bff901
commit
a362edee5e
@ -81,6 +81,16 @@ class Osc(cmdln.Cmdln):
|
|||||||
argument_parser.add_argument(*args, **kwargs)
|
argument_parser.add_argument(*args, **kwargs)
|
||||||
|
|
||||||
arguments = []
|
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(
|
arguments.append(dict(
|
||||||
names=['--debugger'],
|
names=['--debugger'],
|
||||||
action='store_true',
|
action='store_true',
|
||||||
@ -130,24 +140,14 @@ class Osc(cmdln.Cmdln):
|
|||||||
|
|
||||||
_add_parser_arguments_from_data(parser, arguments)
|
_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):
|
def post_argparse(self):
|
||||||
"""merge commandline options into the config"""
|
"""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.
|
# avoid loading config that may trigger prompt for username, password etc.
|
||||||
if not self.options.command:
|
if not self.options.command:
|
||||||
# no command specified
|
# no command specified
|
||||||
|
Loading…
Reference in New Issue
Block a user