2022-01-19 12:44:23 +01:00
|
|
|
import sys
|
2022-05-19 18:09:25 +02:00
|
|
|
import traceback
|
2021-03-03 19:37:35 +01:00
|
|
|
|
2021-08-05 14:21:42 +02:00
|
|
|
from cpl_core.application.application_abc import ApplicationABC
|
|
|
|
from cpl_core.configuration.configuration_abc import ConfigurationABC
|
|
|
|
from cpl_core.console.console import Console
|
|
|
|
from cpl_core.dependency_injection import ServiceProviderABC
|
2021-03-03 18:37:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
class CLI(ApplicationABC):
|
|
|
|
|
2021-03-29 08:56:18 +02:00
|
|
|
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
2021-03-14 16:01:15 +01:00
|
|
|
"""
|
|
|
|
CPL CLI
|
|
|
|
"""
|
2021-03-29 08:56:18 +02:00
|
|
|
ApplicationABC.__init__(self, config, services)
|
2021-03-03 18:37:54 +01:00
|
|
|
|
2021-04-12 19:43:55 +02:00
|
|
|
self._options: list[str] = []
|
2021-03-03 19:37:35 +01:00
|
|
|
|
2021-03-03 18:37:54 +01:00
|
|
|
def configure(self):
|
2022-05-19 08:25:32 +02:00
|
|
|
pass
|
2021-04-12 19:43:55 +02:00
|
|
|
|
2021-03-03 18:37:54 +01:00
|
|
|
def main(self):
|
2021-03-14 16:01:15 +01:00
|
|
|
"""
|
|
|
|
Entry point of the CPL CLI
|
|
|
|
:return:
|
|
|
|
"""
|
2021-03-15 18:25:53 +01:00
|
|
|
try:
|
2022-05-19 19:37:32 +02:00
|
|
|
self._configuration.parse_console_arguments(self._services)
|
2021-03-15 18:25:53 +01:00
|
|
|
except KeyboardInterrupt:
|
2021-03-15 18:28:33 +01:00
|
|
|
Console.write_line()
|
2022-01-19 12:44:23 +01:00
|
|
|
sys.exit()
|
2022-05-19 18:09:25 +02:00
|
|
|
except Exception as e:
|
|
|
|
Console.error(str(e), traceback.format_exc())
|
|
|
|
sys.exit()
|