chore: init work cli gui creation options

This commit is contained in:
Benjamin Labrecque
2026-07-28 11:59:59 +02:00
parent 355957455a
commit e39663cd80
3 changed files with 37 additions and 15 deletions
+5
View File
@@ -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"
+14 -12
View File
@@ -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):
"""
+18 -3
View File
@@ -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 <repo-root>/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 <ui-filename> in 'A_BD_<ui-filename>.ui'; See <repo-root>/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(