Improved help command
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import sys
|
||||
import textwrap
|
||||
from typing import Optional
|
||||
|
||||
from cpl_core.console.console import Console
|
||||
from cpl_core.console.foreground_color_enum import ForegroundColorEnum
|
||||
@@ -21,10 +21,7 @@ class HelpService(CommandABC):
|
||||
def help_message(self) -> str:
|
||||
return textwrap.dedent("""\
|
||||
Lists available command and their short descriptions.
|
||||
Usage: cpl help <command>
|
||||
|
||||
Arguments:
|
||||
command The command to display the help message for
|
||||
Usage: cpl help
|
||||
""")
|
||||
|
||||
def run(self, args: list[str]):
|
||||
@@ -33,20 +30,9 @@ class HelpService(CommandABC):
|
||||
:param args:
|
||||
:return:
|
||||
"""
|
||||
# if len(args) > 0:
|
||||
# command_name = args[0]
|
||||
# command: Optional[CommandABC] = None
|
||||
# for cmd in self._commands:
|
||||
# if cmd.name == command_name or command_name in cmd.aliases:
|
||||
# command = self._services.get_service(cmd.command)
|
||||
#
|
||||
# if command is None:
|
||||
# Console.error(f'Invalid argument: {command_name}')
|
||||
# return
|
||||
#
|
||||
# Console.write_line(command.help_message)
|
||||
#
|
||||
# return
|
||||
if len(args) > 0:
|
||||
Console.error(f'Unexpected argument(s): {", ".join(args)}')
|
||||
sys.exit()
|
||||
|
||||
Console.write_line('Available Commands:')
|
||||
commands = [
|
||||
@@ -68,3 +54,4 @@ class HelpService(CommandABC):
|
||||
Console.write(f'\n\t{name} ')
|
||||
Console.set_foreground_color(ForegroundColorEnum.default)
|
||||
Console.write(f'{description}')
|
||||
Console.write_line('\nRun \'cpl <command> --help\' for command specific information\'s')
|
||||
|
Reference in New Issue
Block a user