From e39663cd80bf7e357490a25a2405018b84d65d83 Mon Sep 17 00:00:00 2001 From: Benjamin Labrecque Date: Tue, 28 Jul 2026 11:59:59 +0200 Subject: [PATCH] chore: init work cli gui creation options --- cli/src/core/enums.py | 5 +++++ cli/src/core/service_creator.py | 26 ++++++++++++++------------ cli/src/service.py | 21 ++++++++++++++++++--- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/cli/src/core/enums.py b/cli/src/core/enums.py index 4e313f3..9d75892 100644 --- a/cli/src/core/enums.py +++ b/cli/src/core/enums.py @@ -13,3 +13,8 @@ class IOC_ENV(str, Enum): def __str__(self) -> str: return self.value + +class GuiOption(str, Enum): + NEW = "new" + EXISTING = "existing" + NONE = "none" diff --git a/cli/src/core/service_creator.py b/cli/src/core/service_creator.py index 3999b89..c379ba8 100644 --- a/cli/src/core/service_creator.py +++ b/cli/src/core/service_creator.py @@ -30,7 +30,7 @@ class ServiceCreator: name: str, ioc_owner: str, ioc_description: str, - ui_filename: str, + ui_filename: str | None, ): self.repo_manager.assert_clean_repo() original_branch = self.repo_manager.get_active_branch_name() @@ -41,9 +41,10 @@ class ServiceCreator: self.ctx.master_hla_names.add_hla_name(service.name_upper) self.ctx.iocs_overview.add_ioc(service, description=ioc_description) self.ctx.master_ioc_subs.update_content(service_name=service.name_upper) - self.ctx.service_manager_ui.update_xml( - service=service, service_name_camel=service.name_camel, ui_filename=ui_filename - ) + if ui_filename: + self.ctx.service_manager_ui.update_xml( + service=service, service_name_camel=service.name_camel, ui_filename=ui_filename + ) branch_name = f"feature/add-service-{service.dir_name}" self.repo_manager.delete_local_branch(branch_name) @@ -90,14 +91,15 @@ class ServiceCreator: "ioc_owner": ioc_owner, }, ) - copier.run_copy( - src_path=str(QT_TEMPLATES_DIR), - dst_path=str(self.ctx.write_paths.qt_dir), - data={ - "service_name_upper": service.name_upper, - "ui_filename": ui_filename, - }, - ) + if ui_filename: + copier.run_copy( + src_path=str(QT_TEMPLATES_DIR), + dst_path=str(self.ctx.write_paths.qt_dir), + data={ + "service_name_upper": service.name_upper, + "ui_filename": ui_filename, + }, + ) def _generate_uv_lock(self, service: Service): """ diff --git a/cli/src/service.py b/cli/src/service.py index cf478a2..53593de 100644 --- a/cli/src/service.py +++ b/cli/src/service.py @@ -2,6 +2,7 @@ import typer from agebd.utils import get_git_root, init_logging from config.paths import Paths +from core.enums import GuiOption from core.git import GitRepoManager from core.service_creator import ServiceCreator from models import ServiceRegistry @@ -38,14 +39,28 @@ def add( "-d", help="See /docs/user/ioc/iocs_overview.md for examples", ), - ui_filename: str = typer.Option( - ..., + gui: GuiOption = typer.Option( + GuiOption.NEW, + "--gui", + "-g", + help="By default, a new GUI is created. You can specificy if a GUI already exists, " + "and this service should use that GUI, or if no GUI is needed for this service", + ), + ui_filename: str | None = typer.Option( + None, "--ui-filename", "-f", - help="The in 'A_BD_.ui'; See /qt/A_BD_ServiceManager.ui for examples", + help="If '--gui=existing', specify the name of the service (in CamelCase) whose UI this service should use", ), ): init_logging() + if gui == GuiOption.EXISTING: + ui_filename = ui_filename + elif gui == GuiOption.NONE: + ui_filename = None + elif gui == GuiOption.NEW: + ui_filename = name + ctx = ServicesContext.load_from_disk(Paths()) service_creator = ServiceCreator(ctx=ctx, repo_manager=GitRepoManager(REPO_ROOT)) service_creator.add_service(