Skip to content

Commit

Permalink
feat(CLI): Add a script to project
Browse files Browse the repository at this point in the history
Also fix --help for commands.

Co-authored-by: Wuestengecko <[email protected]>
  • Loading branch information
ewuerger and Wuestengecko committed Sep 26, 2024
1 parent ceb1efd commit 061c0c5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions capella2polarion/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -128,6 +128,7 @@ def synchronize(
)
capella_to_polarion_cli.force_update = force_update

assert capella_to_polarion_cli.capella_model is not None
converter = model_converter.ModelConverter(
capella_to_polarion_cli.capella_model,
capella_to_polarion_cli.polarion_params.project_id,
Expand Down Expand Up @@ -199,6 +200,7 @@ def render_documents(
configs.iterate_documents()
)

assert capella_to_polarion_cli.capella_model is not None
renderer = document_renderer.DocumentRenderer(
polarion_worker.polarion_data_repo,
capella_to_polarion_cli.capella_model,
Expand Down
2 changes: 1 addition & 1 deletion capella2polarion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(
polarion_url: str,
polarion_pat: str,
polarion_delete_work_items: bool,
capella_model: capellambse.MelodyModel,
capella_model: capellambse.MelodyModel | None,
force_update: bool = False,
) -> None:
self.debug = debug
Expand Down
2 changes: 1 addition & 1 deletion ci-templates/gitlab/render_documents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ capella2polarion_render_documents:

script:
- pip install "capella2polarion${CAPELLA2POLARION_VERSION:+==$CAPELLA2POLARION_VERSION}"
- python -m capella2polarion render-documents
- capella2polarion render-documents
2 changes: 1 addition & 1 deletion ci-templates/gitlab/synchronise_elements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ capella2polarion_synchronise_elements:

script:
- pip install "capella2polarion${CAPELLA2POLARION_VERSION:+==$CAPELLA2POLARION_VERSION}"
- python -m capella2polarion synchronize
- capella2polarion synchronize
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ test = [
"pytest-cov",
]

[project.scripts]
capella2polarion = "capella2polarion.__main__:cli"

[tool.black]
line-length = 79
target-version = ["py312"]
Expand Down

0 comments on commit 061c0c5

Please sign in to comment.