From a3d5737eafdb9b48f479f6f0cbd87521169ad182 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 11 Apr 2021 13:20:32 +0200 Subject: [PATCH] Fixed workspace loading error for update command --- src/cpl_cli/command_handler_service.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cpl_cli/command_handler_service.py b/src/cpl_cli/command_handler_service.py index d9464837..cb6d468a 100644 --- a/src/cpl_cli/command_handler_service.py +++ b/src/cpl_cli/command_handler_service.py @@ -31,6 +31,12 @@ class CommandHandler(ABC): def commands(self) -> list[CommandModel]: return self._commands + @staticmethod + def _project_not_found(): + Error.error( + 'The command requires to be run in an CPL project, but a project could not be found.' + ) + def add_command(self, cmd: CommandModel): self._commands.append(cmd) @@ -71,7 +77,11 @@ class CommandHandler(ABC): if os.path.isfile(project_path_camel_case): project_name = String.convert_to_camel_case(name) - if command.is_workspace_needed or command.is_workspace_needed and project_name is None: + if not command.is_workspace_needed and project_name is None and workspace is None: + self._project_not_found() + return + + else: if workspace is None: Error.error( 'The command requires to be run in an CPL workspace or project, ' @@ -94,9 +104,7 @@ class CommandHandler(ABC): project_json = workspace.projects[project_name] if not os.path.isfile(os.path.join(self._env.working_directory, project_json)): - Error.error( - 'The command requires to be run in an CPL project, but a project could not be found.' - ) + self._project_not_found() return project_json = os.path.join(self._env.working_directory, project_json)