From 4379846881909d1861ed365bbb7248e230448209 Mon Sep 17 00:00:00 2001 From: Benjamin Labrecque Date: Tue, 28 Jul 2026 16:33:32 +0200 Subject: [PATCH] chore: better cli options name --- cli/src/models/gui_config.py | 14 +++++++------- cli/src/service.py | 12 ++++++------ cli/tests/tests/test_service_creator.py | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cli/src/models/gui_config.py b/cli/src/models/gui_config.py index 2804839..6b12f51 100644 --- a/cli/src/models/gui_config.py +++ b/cli/src/models/gui_config.py @@ -8,14 +8,14 @@ from models import ServiceRegistry class GuiConfig(BaseModel): - gui_option: GuiOption + option: GuiOption raw_ui_filename: Optional[str] = None def should_create_new_ui(self): - return self.gui_option == GuiOption.NEW + return self.option == GuiOption.NEW def should_use_existing_ui(self): - return self.gui_option == GuiOption.EXISTING + return self.option == GuiOption.EXISTING @property def ui_filename(self) -> str: @@ -25,10 +25,10 @@ class GuiConfig(BaseModel): return self.raw_ui_filename def assert_valid(self, service_registry: ServiceRegistry): - if self.gui_option == GuiOption.EXISTING: + if self.option == GuiOption.EXISTING: if self.raw_ui_filename is None: raise InvalidCliOptions( - f"Must specify --ui-filename when --gui-option is {GuiOption.EXISTING}" + f"Must specify --gui-existing-service-name when --gui-option is {GuiOption.EXISTING}" ) try: service_registry.assert_service_exists(self.ui_filename) @@ -37,7 +37,7 @@ class GuiConfig(BaseModel): f"Could not find service with name {self.ui_filename} in service_registry." ) from e - if self.gui_option == GuiOption.NONE and self.raw_ui_filename: + if self.option == GuiOption.NONE and self.raw_ui_filename: raise InvalidCliOptions( - f"Cannot specify --ui-filename when --gui-option is {GuiOption.NONE}" + f"Cannot specify --gui-existing-service-name when --gui-option is {GuiOption.NONE}" ) diff --git a/cli/src/service.py b/cli/src/service.py index 624f68f..f6035e6 100644 --- a/cli/src/service.py +++ b/cli/src/service.py @@ -47,17 +47,17 @@ def add( 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( + raw_ui_filename: str | None = typer.Option( None, - "--ui-filename", - "-f", - help="If '--gui=existing', specify the name of the service (in CamelCase) whose UI this service should use", + "--gui-existing-service-name", + "-s", + help="If '--gui=existing', specify the name of an existing service (in CamelCase) whose GUI this new service should use", ), ): init_logging() if gui_option == GuiOption.NEW: - ui_filename = name - gui_config = GuiConfig(gui_option=gui_option, raw_ui_filename=ui_filename) + raw_ui_filename = name + gui_config = GuiConfig(option=gui_option, raw_ui_filename=raw_ui_filename) ctx = ServicesContext.load_from_disk(Paths()) service_creator = ServiceCreator(ctx=ctx, repo_manager=GitRepoManager(REPO_ROOT)) diff --git a/cli/tests/tests/test_service_creator.py b/cli/tests/tests/test_service_creator.py index 8e4c03c..4009ce2 100644 --- a/cli/tests/tests/test_service_creator.py +++ b/cli/tests/tests/test_service_creator.py @@ -71,7 +71,7 @@ def test_add_new_service(tmp_path, mocker: MockerFixture): ctx._write_paths = write_paths service_name = "TestService99-X00" - gui_config = GuiConfig(gui_option=GuiOption.NEW, raw_ui_filename=service_name) + gui_config = GuiConfig(option=GuiOption.NEW, raw_ui_filename=service_name) creator = ServiceCreator(ctx=ctx, repo_manager=mocker.Mock(spec=GitRepoManager)) creator.add_service( name=service_name, @@ -98,7 +98,7 @@ def test_raise_if_gui_options_invalid(gui_option, raw_ui_filename, mocker): paths = Paths(repo_root=TEST_REPO_ROOT) ctx = ServicesContext.load_from_disk(paths) - gui_config = GuiConfig(gui_option=gui_option, raw_ui_filename=raw_ui_filename) + gui_config = GuiConfig(option=gui_option, raw_ui_filename=raw_ui_filename) creator = ServiceCreator(ctx=ctx, repo_manager=mocker.Mock(spec=GitRepoManager)) with pytest.raises(InvalidCliOptions): creator.add_service( @@ -119,7 +119,7 @@ def test_existing_gui_ok(gui_option, raw_ui_filename): paths = Paths(repo_root=TEST_REPO_ROOT) ctx = ServicesContext.load_from_disk(paths) - gui_config = GuiConfig(gui_option=gui_option, raw_ui_filename=raw_ui_filename) + gui_config = GuiConfig(option=gui_option, raw_ui_filename=raw_ui_filename) gui_config.assert_valid(service_registry=ctx.service_registry)