1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-27 10:16:14 +01:00

Merge pull request #1149 from dmach/fix-argparse-conflicts

Do not traceback on conflicting argparse arguments
This commit is contained in:
Daniel Mach 2022-09-26 17:23:11 +02:00 committed by GitHub
commit 1115cb4b9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -174,7 +174,10 @@ class Cmdln:
# add hidden copy of global options so they can be used in any place # add hidden copy of global options so they can be used in any place
self.add_global_options(subparser, suppress=True) self.add_global_options(subparser, suppress=True)
for option_args, option_kwargs in options: for option_args, option_kwargs in options:
subparser.add_argument(*option_args, **option_kwargs) try:
subparser.add_argument(*option_args, **option_kwargs)
except argparse.ArgumentError as e:
print(f"WARNING: Could not add argument '{e.argument_name}' to the '{cmd_name}' sub-command: {e}", file=sys.stderr)
def argparse_error(self, *args, **kwargs): def argparse_error(self, *args, **kwargs):
""" """