1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-03 13:47:25 +03:00

samba-tool: more conventional usage of parser.parse_args

By default parse_args will use sys.argv[1:], which is to say the
command-line without the command name. We have always fed it the
equivalent of sys.argv, then trimmed the command off the result. That
was a bit silly.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall 2022-09-07 15:07:43 +12:00 committed by Andrew Bartlett
parent 9ec0863ff2
commit ed78786989

View File

@ -166,9 +166,8 @@ class Command(object):
def _run(self, *argv):
parser, optiongroups = self._create_parser(self.command_name)
opts, args = parser.parse_args([self.command_name] + list(argv))
opts, args = parser.parse_args(list(argv))
# Filter out options from option groups
args = args[1:]
kwargs = dict(opts.__dict__)
for option_group in parser.option_groups:
for option in option_group.option_list:
@ -288,7 +287,7 @@ class SuperCommand(Command):
f"{self.command_name} <subcommand> (-h|--help)\n")
parser, optiongroups = self._create_parser(self.command_name, epilog=epilog)
opts, args = parser.parse_args([self.command_name] + list(argv))
opts, args = parser.parse_args(list(argv))
parser.print_help()
return -1