Added version command to cli

This commit is contained in:
2020-12-16 14:35:43 +01:00
parent 88362006ef
commit 5fb20035d8
7 changed files with 87 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
from sh_edraft.cli.command.base.command_base import CommandBase
from sh_edraft.console.console import Console
class Interpreter:
@@ -16,13 +17,12 @@ class Interpreter:
input_list = input_string.split(' ')
commands = [type(cmd).__name__.lower() for cmd in self._commands]
command = input_list[0]
args = input_list[1:]
print(command)
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:
print(f'Unexpected command {command}')
Console.error(f'Unexpected command {command}')
else:
print(f'Unexpected command {command}')
Console.error(f'Unexpected command {command}')