Added build command to cli

This commit is contained in:
2020-12-16 16:47:31 +01:00
parent e9c20061d1
commit 3374ffe8db
8 changed files with 104 additions and 112 deletions

View File

@@ -15,16 +15,14 @@ class Interpreter:
def interpret(self, input_string: str):
input_list = input_string.split(' ')
commands = [type(cmd).__name__.lower() for cmd in self._commands]
command = input_list[0]
args = input_list[1:] if len(input_list) > 2 else []
if command in commands:
cmd = next((cmd for cmd in self._commands if type(cmd).__name__.lower() == command), None)
if cmd is not None:
cmd.run(args)
else:
Console.error(f'Unexpected command {command}')
Console.error('Run \'cpl help\'')
args = input_list[1:] if len(input_list) > 1 else []
cmd = next(
(cmd for cmd in self._commands if type(cmd).__name__.lower() == command or command in cmd.aliases),
None)
if cmd is not None:
cmd.run(args)
else:
Console.error(f'Unexpected command {command}')
Console.error('Run \'cpl help\'')