Updated for invalid combination

This commit is contained in:
Dimitris Zlatanidis 2023-03-17 10:03:09 +02:00
parent 29e6b4f08b
commit 5170a7a446

View file

@ -269,19 +269,20 @@ class Argparse(Configs):
def invalid_options(self):
""" Checks for invalid options. """
invalid: list = []
command: list = []
commands: list = []
for arg in self.args:
if arg[0] == '-' and arg in self.commands.keys():
command.append(arg)
commands.append(arg)
elif arg[0] == '-' and arg not in self.options:
invalid.append(arg)
elif arg[0] == '--' and arg not in self.options:
invalid.append(arg)
# Fixed for two or more commands.
if len(command) > 1:
invalid = command
# Fixed for invalid commands combination.
if len(commands) > 1:
print(f"{self.prog_name}: invalid combination '{', '.join(commands)}'")
self.usage.help_minimal()
# Prints error for invalid options.
if invalid: