2021.4.1 #11

Merged
edraft merged 172 commits from 2021.04.01 into 2021.04 2021-03-21 20:04:24 +01:00
3 changed files with 64 additions and 0 deletions
Showing only changes of commit 9581283d7d - Show all commits

20
src/cpl_cli/cli.py Normal file
View File

@ -0,0 +1,20 @@
from cpl.application.application_abc import ApplicationABC
from cpl.console.console import Console
class CLI(ApplicationABC):
def __init__(self):
ApplicationABC.__init__(self)
def configure(self):
if self._services is None:
Console.error('Service provider is empty')
exit()
if self._configuration is None:
Console.error('Configuration is empty')
exit()
def main(self):
Console.write_line(self._configuration)

8
src/cpl_cli/main.py Normal file
View File

@ -0,0 +1,8 @@
from cpl_cli.cli import CLI
from cpl_cli.startup import Startup
if __name__ == '__main__':
cli = CLI()
cli.use_startup(Startup)
cli.build()
cli.run()

36
src/cpl_cli/startup.py Normal file
View File

@ -0,0 +1,36 @@
from typing import Optional
from cpl.application.application_host import ApplicationHost
from cpl.application.application_host_abc import ApplicationHostABC
from cpl.application.startup_abc import StartupABC
from cpl.configuration.configuration_abc import ConfigurationABC
from cpl.dependency_injection.service_provider_base import ServiceProviderABC
class Startup(StartupABC):
def __init__(self):
StartupABC.__init__(self)
self._app_host: Optional[ApplicationHostABC] = None
self._configuration: Optional[ConfigurationABC] = None
self._services: Optional[ServiceProviderABC] = None
def create_application_host(self) -> ApplicationHostABC:
self._app_host = ApplicationHost()
self._configuration = self._app_host.configuration
self._services = self._app_host.services
return self._app_host
def create_configuration(self) -> ConfigurationABC:
self._configuration.add_environment_variables('PYTHON_')
self._configuration.add_environment_variables('CPL_')
self._configuration.add_console_argument('', 'version', ['v'], '')
self._configuration.add_console_argument('-', 'test', ['t'], '')
self._configuration.add_console_argument('-', 'var', ['v'], ':')
self._configuration.add_console_arguments()
return self._configuration
def create_services(self) -> ServiceProviderABC:
return self._services