Updated for doubles

This commit is contained in:
Dimitris Zlatanidis 2023-03-17 13:58:39 +02:00
parent 52a30faf2a
commit aef2f6b5ff
2 changed files with 18 additions and 7 deletions

View file

@ -1,3 +1,7 @@
4.6.2 - 17/03/2023
Updated:
- For doubles options
4.6.1 - 15/03/2023 4.6.1 - 15/03/2023
Updated: Updated:
- For empty arguments - For empty arguments

View file

@ -279,13 +279,15 @@ class Argparse(Configs):
invalid.append(arg) invalid.append(arg)
elif arg[0] == '--' and arg not in self.options: elif arg[0] == '--' and arg not in self.options:
invalid.append(arg) invalid.append(arg)
elif arg[0] == '-' and arg in self.options:
doubles.append(arg) for opt in self.flags:
if opt[0] == '-' and opt in self.options:
if self.flags.count(opt) > 1:
doubles.append(opt)
# Fixed for doubles options. # Fixed for doubles options.
if doubles: if doubles:
for opt in doubles: print(f"{self.prog_name}: invalid double options '{', '.join(doubles)}'")
print(f"{self.prog_name}: invalid double option '{opt}'")
self.usage.help_minimal() self.usage.help_minimal()
# Fixed for invalid commands combination. # Fixed for invalid commands combination.
@ -353,10 +355,15 @@ class Argparse(Configs):
def move_options(self) -> None: def move_options(self) -> None:
""" Move options to the flags and removes from the arguments. """ """ Move options to the flags and removes from the arguments. """
for opt in self.options: new_args: list = []
if opt in self.args:
self.args.remove(opt) for opt in self.args:
if opt in self.options:
self.flags.append(opt) self.flags.append(opt)
else:
new_args.append(opt)
self.args = new_args
def is_file_list_packages(self): def is_file_list_packages(self):
""" Checks if the arg is filelist.pkgs. """ """ Checks if the arg is filelist.pkgs. """