From c8bb0b69be594518f7a1f5e99b55142e1a6bf02a Mon Sep 17 00:00:00 2001 From: ewuerger Date: Thu, 26 Sep 2024 15:03:52 +0200 Subject: [PATCH] feat(CLI): Add a script to project Also fix --help for commands. Co-authored-by: Wuestengecko --- capella2polarion/__main__.py | 4 ++-- ci-templates/gitlab/render_documents.yaml | 2 +- ci-templates/gitlab/synchronise_elements.yml | 2 +- pyproject.toml | 3 +++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/capella2polarion/__main__.py b/capella2polarion/__main__.py index b5174d8..b755745 100644 --- a/capella2polarion/__main__.py +++ b/capella2polarion/__main__.py @@ -58,10 +58,10 @@ def cli( polarion_url: str, polarion_pat: str, polarion_delete_work_items: bool, - capella_model: capellambse.MelodyModel, + capella_model: capellambse.MelodyModel | None, ) -> None: """Synchronise data from Capella to Polarion.""" - if capella_model.diagram_cache is None: + if capella_model is not None and capella_model.diagram_cache is None: logger.warning("It's highly recommended to define a diagram cache!") capella2polarion_cli = Capella2PolarionCli( diff --git a/ci-templates/gitlab/render_documents.yaml b/ci-templates/gitlab/render_documents.yaml index e6156b6..1f03b54 100644 --- a/ci-templates/gitlab/render_documents.yaml +++ b/ci-templates/gitlab/render_documents.yaml @@ -21,4 +21,4 @@ capella2polarion_render_documents: script: - pip install "capella2polarion${CAPELLA2POLARION_VERSION:+==$CAPELLA2POLARION_VERSION}" - - python -m capella2polarion render-documents + - capella2polarion render-documents diff --git a/ci-templates/gitlab/synchronise_elements.yml b/ci-templates/gitlab/synchronise_elements.yml index 72fd944..674d33f 100644 --- a/ci-templates/gitlab/synchronise_elements.yml +++ b/ci-templates/gitlab/synchronise_elements.yml @@ -21,4 +21,4 @@ capella2polarion_synchronise_elements: script: - pip install "capella2polarion${CAPELLA2POLARION_VERSION:+==$CAPELLA2POLARION_VERSION}" - - python -m capella2polarion synchronize + - capella2polarion synchronize diff --git a/pyproject.toml b/pyproject.toml index 3890852..42cac83 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,6 +60,9 @@ test = [ "pytest-cov", ] +[project.scripts] +capella2polarion = "capella2polarion.__main__:cli" + [tool.black] line-length = 79 target-version = ["py312"]