diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5adad07e..baf1d082 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -22,9 +22,13 @@
-
+
+
+
+
+
@@ -89,14 +93,14 @@
+
-
-
+
@@ -485,13 +489,6 @@
1605881914521
-
- 1608047655667
-
-
-
- 1608047655667
-
1608048544558
@@ -828,7 +825,14 @@
1614797275948
-
+
+ 1614797335732
+
+
+
+ 1614797335732
+
+
@@ -844,7 +848,6 @@
-
@@ -869,7 +872,8 @@
-
+
+
diff --git a/src/cpl/application/application_abc.py b/src/cpl/application/application_abc.py
index d680c542..1f689092 100644
--- a/src/cpl/application/application_abc.py
+++ b/src/cpl/application/application_abc.py
@@ -1,3 +1,4 @@
+import atexit
from abc import ABC, abstractmethod
from typing import Type, Optional
@@ -20,6 +21,10 @@ class ApplicationABC(ABC):
def use_startup(self, startup: Type[StartupABC]):
self._startup = startup()
+ @staticmethod
+ def output_at_exit():
+ atexit.register(Console.close)
+
def build(self):
if self._startup is not None:
self._app_host = self._startup.create_application_host()
diff --git a/src/cpl/application/application_host.py b/src/cpl/application/application_host.py
index 73e77a5e..a7fb0659 100644
--- a/src/cpl/application/application_host.py
+++ b/src/cpl/application/application_host.py
@@ -1,4 +1,3 @@
-import atexit
from datetime import datetime
from cpl.application.application_host_abc import ApplicationHostABC
@@ -6,7 +5,6 @@ from cpl.application.application_runtime import ApplicationRuntime
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
from cpl.configuration.configuration import Configuration
from cpl.configuration.configuration_abc import ConfigurationABC
-from cpl.console.console import Console
from cpl.dependency_injection.service_provider import ServiceProvider
from cpl.dependency_injection.service_provider_base import ServiceProviderABC
@@ -25,8 +23,6 @@ class ApplicationHost(ApplicationHostABC):
self._start_time: datetime = datetime.now()
self._end_time: datetime = datetime.now()
- atexit.register(Console.close)
-
@property
def configuration(self) -> ConfigurationABC:
return self._config
diff --git a/src/cpl_cli/cli.py b/src/cpl_cli/cli.py
index 443221ca..580e39ec 100644
--- a/src/cpl_cli/cli.py
+++ b/src/cpl_cli/cli.py
@@ -1,9 +1,9 @@
from typing import Optional
from cpl.application.application_abc import ApplicationABC
-from cpl.console.console import Console
from cpl_cli.command import Command
from cpl_cli.command_handler import CommandHandler
+from cpl_cli.error import Error
from cpl_cli.commands.help import Help
from cpl_cli.commands.version import Version
@@ -23,8 +23,7 @@ class CLI(ApplicationABC):
def main(self):
if len(self._configuration.additional_arguments) < 1:
- Console.error(f'Expected command')
- Console.error('Run \'cpl help\'')
+ Error.error(f'Expected command')
return
self._command_handler.handle(self._configuration.additional_arguments[0], self._configuration.additional_arguments[1:])
diff --git a/src/cpl_cli/command_handler.py b/src/cpl_cli/command_handler.py
index 7e885b3c..60150e5f 100644
--- a/src/cpl_cli/command_handler.py
+++ b/src/cpl_cli/command_handler.py
@@ -18,5 +18,4 @@ class CommandHandler(ServiceABC):
def handle(self, cmd: str, args: list[str]):
for command in self._commands:
if cmd == command.name or cmd in command.aliases:
- print(command.command)
command.command.run(args)
diff --git a/src/cpl_cli/error.py b/src/cpl_cli/error.py
new file mode 100644
index 00000000..21f4cf50
--- /dev/null
+++ b/src/cpl_cli/error.py
@@ -0,0 +1,9 @@
+from cpl.console.console import Console
+
+
+class Error:
+
+ @staticmethod
+ def error(message: str):
+ Console.error(message)
+ Console.error('Run \'cpl help\'')