mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-31 10:26:39 +01:00
Updated for invalid options
This commit is contained in:
parent
545c9ce076
commit
34d8e20726
1 changed files with 8 additions and 4 deletions
|
@ -271,6 +271,7 @@ class Argparse(Configs):
|
|||
commands: list = []
|
||||
options: list = []
|
||||
invalid: list = []
|
||||
error: int = 0
|
||||
|
||||
for arg in self.args:
|
||||
if arg in self.options:
|
||||
|
@ -287,18 +288,21 @@ class Argparse(Configs):
|
|||
|
||||
# Avoid to combine two or more options.
|
||||
if len(options) != len(set(options)):
|
||||
print(f"{self.prog_name}: you added the same {', '.join(options)} options.")
|
||||
self.usage.help_minimal()
|
||||
print(f"{self.prog_name}: you added the same \'{', '.join(options)}\' options.")
|
||||
error: int = 1
|
||||
|
||||
# Avoid to combine two or more commands.
|
||||
if len(commands) > 1:
|
||||
print(f"{self.prog_name}: you can't combine {', '.join(commands)} commands.")
|
||||
self.usage.help_minimal()
|
||||
print(f"{self.prog_name}: you can't combine \'{', '.join(commands)}\' commands.")
|
||||
error: int = 1
|
||||
|
||||
# Prints error for invalid options.
|
||||
if invalid:
|
||||
for opt in invalid:
|
||||
print(f"{self.prog_name}: invalid option '{opt}'")
|
||||
error: int = 1
|
||||
|
||||
if error:
|
||||
self.usage.help_minimal()
|
||||
|
||||
def split_options(self) -> None:
|
||||
|
|
Loading…
Reference in a new issue