diff --git a/slpkg/main.py b/slpkg/main.py index d939d647..39735a47 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -282,7 +282,7 @@ class Argparse(Configs): for opt in self.flags: if opt not in flags and opt not in ['--help', '--version']: - self.usage.error_for_options(flags) + self.usage.error_for_options(command, flags) def choose_packages(self, packages: list, method: str): """ Choose packages with dialog utility and -S, --search flag. """ diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 9b4283d2..a5ae4f24 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -77,12 +77,15 @@ class Usage(Configs): print(args) raise SystemExit(status) - def error_for_options(self, flags: list): + def error_for_options(self, command: str, flags: list): """ Error messages for flags. """ flags.reverse() # Put first the short options. print(f'Usage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] ' f'[{self.cyan}COMMAND{self.endc}] \n' f"Try 'slpkg --help' for help.\n") - raise SystemExit(f"{self.red}Error:{self.endc} Got an unexpected extra option.\n" - f"\nTry to use: {', '.join(flags)}") + print(f"{self.red}Error:{self.endc} Got an unexpected extra option.\n" + f"\n{self.bold}COMMAND:{self.endc} {self.cyan}{command}{self.endc}" + f"\n{self.bold}OPTIONS:{self.endc} {self.yellow}{', '.join(flags)}{self.endc}\n") + print('If you need more information try to use slpkg manpage.') + raise SystemExit(1) diff --git a/slpkg/views/help_commands.py b/slpkg/views/help_commands.py index a5e167e6..9e55c58b 100644 --- a/slpkg/views/help_commands.py +++ b/slpkg/views/help_commands.py @@ -56,8 +56,9 @@ class Help(Configs): help_commands['-e'] = help_commands['dependees'] help_commands['-t'] = help_commands['tracking'] - print(f'Usage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] \n') + print(f'Usage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] ') + print(f"Try 'slpkg --help' for help.\n") + print(f'{self.bold}{self.green}Help: {self.endc}{help_commands[self.command]}\n') print(f"{self.bold}COMMAND{self.endc}: {self.cyan}{self.command}{self.endc}") print(f"{self.bold}OPTIONS:{self.endc} {self.yellow}{', '.join(self.flags)}{self.endc}\n") - print(f'{self.bold}{self.green}Help: {self.endc}{help_commands[self.command]}\n') print('If you need more information try to use slpkg manpage.')