2021.4.7 #28

Manually merged
edraft merged 9 commits from 2021.4.7 into 2021.4.post1 2021-04-13 15:47:25 +02:00
2 changed files with 19 additions and 3 deletions
Showing only changes of commit 696c62292b - Show all commits

View File

@ -30,6 +30,7 @@ class CLI(ApplicationABC):
ApplicationABC.__init__(self, config, services)
self._command_handler: Optional[CommandHandler] = None
self._options: list[str] = []
def configure(self):
self._command_handler: CommandHandler = self._services.get_service(CommandHandler)
@ -47,6 +48,9 @@ class CLI(ApplicationABC):
self._command_handler.add_command(CommandModel('update', ['u', 'U'], UpdateService, False, True, True))
self._command_handler.add_command(CommandModel('version', ['v', 'V'], VersionService, False, False, False))
self._command_handler.add_command(CommandModel('--help', ['-h', '-H'], HelpService, False, False, False))
self._options.append('--help')
def main(self):
"""
Entry point of the CPL CLI
@ -56,6 +60,15 @@ class CLI(ApplicationABC):
command = None
args = []
if len(self._configuration.additional_arguments) > 0:
is_option = False
for opt in self._options:
if opt in self._configuration.additional_arguments:
is_option = True
command = opt
args = self._configuration.additional_arguments
args.remove(opt)
if not is_option:
command = self._configuration.additional_arguments[0]
if len(self._configuration.additional_arguments) > 1:
args = self._configuration.additional_arguments[1:]

View File

@ -69,6 +69,9 @@ class Startup(StartupABC):
self._configuration.add_console_argument(ConsoleArgument('', 'uninstall', ['ui', 'UI'], ' '))
self._configuration.add_console_argument(ConsoleArgument('', 'update', ['u', 'U'], ''))
self._configuration.add_console_argument(ConsoleArgument('', 'version', ['v', 'V'], ''))
self._configuration.add_console_argument(ConsoleArgument('', '--help', ['-h', '-H'], ''))
self._configuration.add_console_arguments(error=False)
return self._configuration