Skip to content

Commit 75adb0f

Browse files
committed
✨ feat(duties.py): add a duty to setup the CLI globally
1 parent 142fa22 commit 75adb0f

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

template/duties.py.jinja

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def _verify_uv_installed(ctx: Context, duty_name: str) -> None:
5555
)
5656
else:
5757
raise ValueError(
58-
f"make: {duty_name}: uv must be installed, see https://docs.astral.sh/uv/getting-started/installation/"
58+
f"make: {duty_name.replace('_', '-')}: uv must be installed, "
59+
"see https://docs.astral.sh/uv/getting-started/installation/"
5960
){% if dockerfile %}
6061

6162

@@ -233,7 +234,27 @@ def setup_dev(ctx: Context) -> None:
233234
ctx.run(
234235
["uv", "sync"], title="Creating virtual environment using uv and installing the package"
235236
)
236-
ctx.run(["uv", "run", "pre-commit", "install", "-f"], title="Setting up pre-commit"){% if dockerfile %}
237+
ctx.run(["uv", "run", "pre-commit", "install", "-f"], title="Setting up pre-commit"){% if with_typer_cli %}
238+
239+
240+
@duty{% if dockerfile %}(
241+
skip_if=_is_running_in_docker(),
242+
skip_reason="setup-cli: skipped => Running inside a Docker container",
243+
)
244+
{%- endif %}
245+
def setup_cli(ctx: Context) -> None:
246+
"""Install the project's CLI globally using `uv`.
247+
248+
```bash
249+
make setup-cli
250+
```
251+
252+
Use `uv` to globally install the CLI defined in the current project.
253+
This allows you to invoke the CLI directly from the command line, without activating
254+
a virtual environment.
255+
"""
256+
_verify_uv_installed(ctx, "setup_cli")
257+
ctx.run(["uv", "tool", "install", "."], title="Installing the CLI globally via uv"){% endif %}{% if dockerfile %}
237258

238259

239260
@duty(

0 commit comments

Comments
 (0)