Updated for helps

This commit is contained in:
Dimitris Zlatanidis 2023-02-27 13:33:57 +02:00
parent a212c01bd9
commit 124c237242
3 changed files with 10 additions and 6 deletions

View file

@ -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. """

View file

@ -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}] <packages>\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)

View file

@ -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}] <packages>\n')
print(f'Usage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] <packages>')
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.')