From ed78786989779f31d97de2aa81b06ef0c0ad7f39 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Wed, 7 Sep 2022 15:07:43 +1200 Subject: [PATCH] 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 --- python/samba/netcmd/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 -- 2.47.3