Skip to content

Commit bfb093b

Browse files
committed
chore: Switched from Typer to Cyclopts
Cyclopts is similar to Typer, but has advantages like Pydantic support.
1 parent 563e9f5 commit bfb093b

5 files changed

Lines changed: 73 additions & 40 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ requires-python = ">=3.10"
1111
dependencies = [
1212
"cloud-pipelines>=0.26.3.12",
1313
"cloud-pipelines-backend",
14-
"typer>=0.24.1",
14+
"cyclopts>=3.0",
1515
]
1616

1717
[project.urls]

tangle_cli/api_cli.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import typer
1+
import cyclopts
22

3-
app = typer.Typer(no_args_is_help=True)
3+
app = cyclopts.App(name="api")
44

5-
pipeline_runs_app = typer.Typer(no_args_is_help=True)
6-
app.add_typer(pipeline_runs_app, name="pipeline-runs", no_args_is_help=True)
5+
pipeline_runs_app = cyclopts.App(name="pipeline-runs")
6+
app.command(pipeline_runs_app)
77

8-
execution_nodes_app = typer.Typer(no_args_is_help=True)
9-
app.add_typer(execution_nodes_app, name="execution-nodes", no_args_is_help=True)
8+
execution_nodes_app = cyclopts.App(name="execution-nodes")
9+
app.command(execution_nodes_app)
1010

11-
artifacts_app = typer.Typer(no_args_is_help=True)
12-
app.add_typer(artifacts_app, name="artifacts", no_args_is_help=True)
11+
artifacts_app = cyclopts.App(name="artifacts")
12+
app.command(artifacts_app)
1313

14-
published_components_app = typer.Typer(no_args_is_help=True)
15-
app.add_typer(published_components_app, name="published-components", no_args_is_help=True)
14+
published_components_app = cyclopts.App(name="published-components")
15+
app.command(published_components_app)

tangle_cli/cli.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
import typer
1+
import cyclopts
22

33
from . import api_cli
44
from . import components_cli
55

6-
app = typer.Typer(
7-
no_args_is_help=True,
8-
add_completion=False,
9-
rich_markup_mode=None,
10-
suggest_commands=True,
11-
)
6+
app = cyclopts.App()
127

13-
app.add_typer(api_cli.app, name="api")
14-
app.add_typer(components_cli.app, name="components")
8+
app.command(api_cli.app)
9+
app.command(components_cli.app)
1510

1611

1712
if __name__ == "__main__":

tangle_cli/components_cli.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
import pathlib
22

3-
import typer
3+
import cyclopts
44

5-
app = typer.Typer(no_args_is_help=True)
5+
app = cyclopts.App(name="components")
66

7-
generate_app = typer.Typer(no_args_is_help=True)
8-
app.add_typer(generate_app, name="generate", no_args_is_help=True)
7+
generate_app = cyclopts.App(name="generate")
8+
app.command(generate_app)
99

10-
component_references_app = typer.Typer(no_args_is_help=True)
11-
app.add_typer(
12-
component_references_app, name="component-references", no_args_is_help=True
13-
)
10+
component_references_app = cyclopts.App(name="component-references")
11+
app.command(component_references_app)
1412

15-
annotations_app = typer.Typer(no_args_is_help=True)
16-
app.add_typer(annotations_app, name="annotations", no_args_is_help=True)
13+
annotations_app = cyclopts.App(name="annotations")
14+
app.command(annotations_app)
1715

1816
# region components
1917

@@ -34,15 +32,15 @@ def components_set_container_image(component_path: str):
3432
# region components/annotations
3533

3634

37-
@annotations_app.command(name="set", no_args_is_help=True)
35+
@annotations_app.command(name="set")
3836
def components_annotations_set(
3937
component_path: str, key: str, value: str, output_component_path: str | None = None
4038
):
4139
"""Sets annotation value in component file."""
4240
raise NotImplementedError()
4341

4442

45-
@annotations_app.command(name="get", no_args_is_help=True)
43+
@annotations_app.command(name="get")
4644
def components_annotations_get(component_path: str, keys: list[str]):
4745
"""Sets annotation values from component file."""
4846
print(locals())
@@ -54,8 +52,11 @@ def components_annotations_get(component_path: str, keys: list[str]):
5452

5553
# region components/generate
5654

55+
_from_template_app = cyclopts.App(name="from-template", show=False)
56+
generate_app.command(_from_template_app)
5757

58-
@generate_app.command(name="from-template", hidden=True)
58+
59+
@_from_template_app.default
5960
def components_generate_from_template(
6061
template_name: str,
6162
output_component_path: pathlib.Path,
@@ -65,10 +66,8 @@ def components_generate_from_template(
6566

6667
@generate_app.command(name="from-python-function")
6768
def components_generate_from_python_function(output_component_path: str):
68-
"""
69-
Generates component from a Python function
70-
"""
69+
"""Generates component from a Python function"""
7170
raise NotImplementedError()
7271

7372

74-
# endregion
73+
# endregion

uv.lock

Lines changed: 42 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)