Coverage for aipyapp/cli/command/cmd_help.py: 0%
29 statements
« prev ^ index » next coverage.py v7.10.3, created at 2025-08-11 12:02 +0200
« prev ^ index » next coverage.py v7.10.3, created at 2025-08-11 12:02 +0200
1from rich import print
3from ... import T
4from .base import Completable
5from .base_parser import ParserCommand
6from .utils import print_table
8class HelpCommand(ParserCommand):
9 name = 'help'
10 description = T('Show available commands or detailed help for a specific command')
12 def add_arguments(self, parser):
13 parser.add_argument('target_command', nargs='?', help='Command to show detailed help for')
15 def get_arg_values(self, arg, subcommand=None, partial_value=''):
16 if arg.name == 'target_command':
17 return [Completable(cmd.name, cmd.description) for cmd in self.manager.commands.values()]
18 else:
19 return []
21 def execute(self, args):
22 manager = self.manager
23 if args.target_command:
24 if args.target_command in manager.commands:
25 parser = manager.commands[args.target_command].parser
26 print(f"Help for command '{args.target_command}':")
27 print(parser.format_help())
28 else:
29 print(f"Unknown command: {args.target_command}")
30 else:
31 rows = []
32 for cmd, cmd_instance in sorted(manager.commands.items()):
33 rows.append([f"/{cmd}", cmd_instance.description])
34 print_table(rows, headers=[T('Command'), T('Description')], title=T('Available commands'))
35 print()
36 print(T("Or directly enter the question to be processed by AI, for example:\n>> Who are you?"))
37 print()