mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-03 06:56:44 +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 = []
|
commands: list = []
|
||||||
options: list = []
|
options: list = []
|
||||||
invalid: list = []
|
invalid: list = []
|
||||||
|
error: int = 0
|
||||||
|
|
||||||
for arg in self.args:
|
for arg in self.args:
|
||||||
if arg in self.options:
|
if arg in self.options:
|
||||||
|
@ -287,18 +288,21 @@ class Argparse(Configs):
|
||||||
|
|
||||||
# Avoid to combine two or more options.
|
# Avoid to combine two or more options.
|
||||||
if len(options) != len(set(options)):
|
if len(options) != len(set(options)):
|
||||||
print(f"{self.prog_name}: you added the same {', '.join(options)} options.")
|
print(f"{self.prog_name}: you added the same \'{', '.join(options)}\' options.")
|
||||||
self.usage.help_minimal()
|
error: int = 1
|
||||||
|
|
||||||
# Avoid to combine two or more commands.
|
# Avoid to combine two or more commands.
|
||||||
if len(commands) > 1:
|
if len(commands) > 1:
|
||||||
print(f"{self.prog_name}: you can't combine {', '.join(commands)} commands.")
|
print(f"{self.prog_name}: you can't combine \'{', '.join(commands)}\' commands.")
|
||||||
self.usage.help_minimal()
|
error: int = 1
|
||||||
|
|
||||||
# Prints error for invalid options.
|
# Prints error for invalid options.
|
||||||
if invalid:
|
if invalid:
|
||||||
for opt in invalid:
|
for opt in invalid:
|
||||||
print(f"{self.prog_name}: invalid option '{opt}'")
|
print(f"{self.prog_name}: invalid option '{opt}'")
|
||||||
|
error: int = 1
|
||||||
|
|
||||||
|
if error:
|
||||||
self.usage.help_minimal()
|
self.usage.help_minimal()
|
||||||
|
|
||||||
def split_options(self) -> None:
|
def split_options(self) -> None:
|
||||||
|
|
Loading…
Reference in a new issue