mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-11-16 07:47:35 +01:00
Updated for doubles
This commit is contained in:
parent
52a30faf2a
commit
aef2f6b5ff
2 changed files with 18 additions and 7 deletions
|
@ -1,3 +1,7 @@
|
|||
4.6.2 - 17/03/2023
|
||||
Updated:
|
||||
- For doubles options
|
||||
|
||||
4.6.1 - 15/03/2023
|
||||
Updated:
|
||||
- For empty arguments
|
||||
|
|
|
@ -279,13 +279,15 @@ class Argparse(Configs):
|
|||
invalid.append(arg)
|
||||
elif arg[0] == '--' and arg not in self.options:
|
||||
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.
|
||||
if doubles:
|
||||
for opt in doubles:
|
||||
print(f"{self.prog_name}: invalid double option '{opt}'")
|
||||
print(f"{self.prog_name}: invalid double options '{', '.join(doubles)}'")
|
||||
self.usage.help_minimal()
|
||||
|
||||
# Fixed for invalid commands combination.
|
||||
|
@ -353,10 +355,15 @@ class Argparse(Configs):
|
|||
|
||||
def move_options(self) -> None:
|
||||
""" Move options to the flags and removes from the arguments. """
|
||||
for opt in self.options:
|
||||
if opt in self.args:
|
||||
self.args.remove(opt)
|
||||
new_args: list = []
|
||||
|
||||
for opt in self.args:
|
||||
if opt in self.options:
|
||||
self.flags.append(opt)
|
||||
else:
|
||||
new_args.append(opt)
|
||||
|
||||
self.args = new_args
|
||||
|
||||
def is_file_list_packages(self):
|
||||
""" Checks if the arg is filelist.pkgs. """
|
||||
|
|
Loading…
Reference in a new issue