diff --git a/src/cpl_cli/command/run_service.py b/src/cpl_cli/command/run_service.py new file mode 100644 index 00000000..e6be3878 --- /dev/null +++ b/src/cpl_cli/command/run_service.py @@ -0,0 +1,53 @@ +import os +import textwrap + +from cpl_cli.command_abc import CommandABC +from cpl_core.console.console import Console +from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC +from cpl_cli.configuration.build_settings import BuildSettings +from cpl_cli.configuration.project_settings import ProjectSettings +from cpl_cli.live_server.live_server_thread import LiveServerThread + + +class RunService(CommandABC): + + def __init__(self, env: ApplicationEnvironmentABC, project_settings: ProjectSettings, build_settings: BuildSettings): + """ + Service for the CLI command start + :param env: + :param project_settings: + :param build_settings: + """ + CommandABC.__init__(self) + + self._env = env + self._project_settings = project_settings + self._build_settings = build_settings + + self._src_dir = os.path.join(self._env.working_directory, self._build_settings.source_path) + + self._args: list[str] = [] + + @property + def help_message(self) -> str: + return textwrap.dedent("""\ + Starts your application. + Usage: cpl run + """) + + def execute(self, args: list[str]): + """ + Entry point of command + :param args: + :return: + """ + ls_thread = LiveServerThread( + self._project_settings.python_executable, + self._src_dir, + self._args, + self._env, + self._build_settings + ) + ls_thread.start() + ls_thread.join() + Console.write_line() diff --git a/src/cpl_cli/cpl_cli.json b/src/cpl_cli/cpl_cli.json index d0ecf4ec..3aa44d54 100644 --- a/src/cpl_cli/cpl_cli.json +++ b/src/cpl_cli/cpl_cli.json @@ -4,7 +4,7 @@ "Version": { "Major": "2022", "Minor": "6", - "Micro": "1.dev4" + "Micro": "13" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", @@ -16,7 +16,7 @@ "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "cpl-core>=2022.6.1.dev4" + "cpl-core>=2022.6.13" ], "PythonVersion": ">=3.10", "PythonPath": {}, diff --git a/src/cpl_cli/startup_argument_extension.py b/src/cpl_cli/startup_argument_extension.py index bca0aa46..1430e699 100644 --- a/src/cpl_cli/startup_argument_extension.py +++ b/src/cpl_cli/startup_argument_extension.py @@ -10,6 +10,7 @@ from cpl_cli.command.install_service import InstallService from cpl_cli.command.new_service import NewService from cpl_cli.command.publish_service import PublishService from cpl_cli.command.remove_service import RemoveService +from cpl_cli.command.run_service import RunService from cpl_cli.command.start_service import StartService from cpl_cli.command.uninstall_service import UninstallService from cpl_cli.command.update_service import UpdateService @@ -84,6 +85,7 @@ class StartupArgumentExtension(StartupExtensionABC): config.create_console_argument(ArgumentTypeEnum.Executable, '', 'publish', ['p', 'P'], PublishService, True, validators=[ProjectValidator]) config.create_console_argument(ArgumentTypeEnum.Executable, '', 'remove', ['r', 'R'], RemoveService, True, validators=[WorkspaceValidator]) \ .add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S']) + config.create_console_argument(ArgumentTypeEnum.Executable, '', 'run', [], RunService, True, validators=[ProjectValidator]) config.create_console_argument(ArgumentTypeEnum.Executable, '', 'start', ['s', 'S'], StartService, True, validators=[ProjectValidator]) config.create_console_argument(ArgumentTypeEnum.Executable, '', 'uninstall', ['ui', 'UI'], UninstallService, True, validators=[ProjectValidator]) \ .add_console_argument(ArgumentTypeEnum.Flag, '--', 'virtual', ['v', 'V']) \ @@ -110,6 +112,7 @@ class StartupArgumentExtension(StartupExtensionABC): services.add_transient(NewService) services.add_transient(PublishService) services.add_transient(RemoveService) + services.add_transient(RunService) services.add_transient(StartService) services.add_transient(UninstallService) services.add_transient(UpdateService) diff --git a/src/cpl_core/configuration/configuration.py b/src/cpl_core/configuration/configuration.py index 4746808b..a0d1c6c1 100644 --- a/src/cpl_core/configuration/configuration.py +++ b/src/cpl_core/configuration/configuration.py @@ -339,7 +339,7 @@ class Configuration(ConfigurationABC): prevent = exe.prevent_next_executable success = True except Exception as e: - Console.error('An error occurred while executing arguments.', traceback.format_exc()) + Console.error('An error occurred while executing arguments.') sys.exit() return success diff --git a/src/cpl_core/cpl_core.json b/src/cpl_core/cpl_core.json index addfe9be..76e5aa9a 100644 --- a/src/cpl_core/cpl_core.json +++ b/src/cpl_core/cpl_core.json @@ -4,7 +4,7 @@ "Version": { "Major": "2022", "Minor": "6", - "Micro": "1.dev4" + "Micro": "13" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/src/cpl_query/cpl_query.json b/src/cpl_query/cpl_query.json index 3d143d21..3f69f1d3 100644 --- a/src/cpl_query/cpl_query.json +++ b/src/cpl_query/cpl_query.json @@ -4,7 +4,7 @@ "Version": { "Major": "2022", "Minor": "6", - "Micro": "1.dev4" + "Micro": "13" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", @@ -16,7 +16,7 @@ "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "cpl-core>=2022.6.1.dev4" + "cpl-core>=2022.6.13" ], "PythonVersion": ">=3.10", "PythonPath": {},