From 15d938b172e3de1fc7ad23e8d3bbd7585b5e68cd Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 26 May 2022 21:01:41 +0200 Subject: [PATCH] Fixed handing of unregistered console arguments --- src/cpl_core/configuration/configuration.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cpl_core/configuration/configuration.py b/src/cpl_core/configuration/configuration.py index 9b344ace..6ea17122 100644 --- a/src/cpl_core/configuration/configuration.py +++ b/src/cpl_core/configuration/configuration.py @@ -215,16 +215,11 @@ class Configuration(ConfigurationABC): # flags elif isinstance(arg, FlagArgument): - if arg_str.startswith(arg.token) \ - and arg_str_without_token == arg.name or arg_str_without_token in arg.aliases: + if arg_str.startswith(arg.token) and arg_str_without_token == arg.name or arg_str_without_token in arg.aliases: self._additional_arguments.append(arg.name) self._handled_args.append(arg_str) self._parse_arguments(executables, arg_list[i + 1:], arg.console_arguments) - # add left over values to args - if arg_str not in self._additional_arguments and arg_str not in self._handled_args: - self._additional_arguments.append(arg_str) - def add_environment_variables(self, prefix: str): for env_var in os.environ.keys(): if not env_var.startswith(prefix): @@ -310,6 +305,10 @@ class Configuration(ConfigurationABC): arg_list = sys.argv[1:] executables: list[ExecutableArgument] = [] self._parse_arguments(executables, arg_list, self._argument_types) + for arg_str in arg_list: + # add left over values to args + if arg_str not in self._additional_arguments and arg_str not in self._handled_args: + self._additional_arguments.append(arg_str) except Exception as e: Console.error('An error occurred while parsing arguments.') sys.exit()