diff --git a/slpkg/main.py b/slpkg/main.py index 17201cf1..901912ff 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -274,11 +274,15 @@ class Argparse(Configs): Result: ['-i', '-y', '-j', '-R'] """ invalid_options: list = [] + commands: list = [] for args in self.args: if args[0] == '-' and args[:2] != '--' and len(args) >= 3 and '=' not in args: self.args.remove(args) for opt in list(map(lambda item: f'-{item}', [arg for arg in list(args[1:])])): + if opt in self.commands.keys(): + commands.append(opt) + if opt in self.commands.keys(): self.args.insert(0, opt) continue @@ -287,8 +291,14 @@ class Argparse(Configs): self.args.append(opt) + if len(commands) > 1: + print(f"slpkg: You can't combine {', '.join(commands)} commands.") + self.usage.help_minimal() + if invalid_options: - self.usage.help_short() + for opt in invalid_options: + print(f"slpkg: invalid option '{opt}'") + self.usage.help_minimal() def split_options_from_args(self) -> None: """ Split options from arguments. diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 06308318..0c361e23 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -17,6 +17,16 @@ class Usage(Configs): self.yellow: str = color['yellow'] self.endc: str = color['endc'] + def help_minimal(self): + """ Prints the minimal help menu. """ + args = ( + f'\nUsage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] ' + f'[FILELIST|PACKAGES...]\n' + f"\nTry '{self.prog_name} --help' for more options.\n") + + print(args) + raise SystemExit(1) + def help_short(self) -> NoReturn: """ Prints the short menu. """ args = (