From: Douglas Bagnall Date: Wed, 7 Sep 2022 03:07:43 +0000 (+1200) Subject: samba-tool: more conventional usage of parser.parse_args X-Git-Tag: talloc-2.4.0~1127 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ed78786989779f31d97de2aa81b06ef0c0ad7f39;p=thirdparty%2Fsamba.git 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 Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/netcmd/__init__.py b/python/samba/netcmd/__init__.py index a2ad180b2c3..c51ffc1b2cd 100644 --- a/python/samba/netcmd/__init__.py +++ b/python/samba/netcmd/__init__.py @@ -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} (-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