Skip to content

Commit 5431c8e

Browse files
jschfflrclaude
andcommitted
fix: address review findings for install command
- No-flag usage now exits with code 83 (validation error) instead of 0 - Print "Replacing existing skills" message before rmtree - Add integration test for install(skills=True) happy path - Mention `install --skills` in SKILL.md setup section Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0047bd2 commit 5431c8e

3 files changed

Lines changed: 23 additions & 13 deletions

File tree

src/qodev_gitlab_cli/commands/install.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def _install_skills(target_root: Path | None = None) -> Path:
2323
source = files("qodev_gitlab_cli") / "skills"
2424

2525
if dest.exists():
26+
console.print(f"Replacing existing skills at {dest}")
2627
shutil.rmtree(dest)
2728
dest.mkdir(parents=True)
2829

@@ -49,10 +50,10 @@ def install(
4950
skills: Annotated[bool, Parameter(name="--skills", help="Install AI agent skill files", negative="")] = False,
5051
) -> None:
5152
"""Install CLI resources into the current workspace."""
52-
if skills:
53-
dest = _install_skills()
54-
console.print(f"[green]Installed skills to {dest}[/green]")
55-
else:
56-
console.print("Usage: qodev-gitlab install --skills")
57-
console.print("")
58-
console.print(" --skills Copy AI agent skill files to .claude/skills/qodev-gitlab/")
53+
if not skills:
54+
from qodev_gitlab_cli.output import error
55+
56+
error("No install target specified. Use: qodev-gitlab install --skills", code="validation", exit_code=83)
57+
58+
dest = _install_skills()
59+
console.print(f"[green]Installed skills to {dest}[/green]")

src/qodev_gitlab_cli/skills/SKILL.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Agent-friendly CLI for the GitLab API. Designed for AI coding agents with struct
77
```bash
88
pip install qodev-gitlab-cli
99
export GITLAB_TOKEN="glpat-..."
10+
11+
# Install skill files into the current workspace
12+
qodev-gitlab install --skills
1013
```
1114

1215
The CLI auto-detects the current GitLab project from the git remote. Override with `--project GROUP/NAME` or `-p GROUP/NAME`.

tests/test_install.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
from pathlib import Path
66
from unittest.mock import patch
77

8-
from qodev_gitlab_cli.commands.install import _install_skills
8+
import pytest
9+
10+
from qodev_gitlab_cli.commands.install import _install_skills, install
911

1012

1113
class TestInstallSkills:
@@ -44,11 +46,15 @@ def test_replaces_existing_directory(self, tmp_path: Path) -> None:
4446
assert not stale.exists()
4547
assert (dest / "SKILL.md").is_file()
4648

47-
def test_no_flag_shows_guidance(self) -> None:
48-
from qodev_gitlab_cli.commands.install import install
49-
50-
with patch("qodev_gitlab_cli.commands.install.console") as mock_console:
49+
def test_no_flag_exits_with_validation_error(self) -> None:
50+
with pytest.raises(SystemExit, match="83"):
5151
install(skills=False)
5252

53+
def test_skills_flag_prints_success(self, tmp_path: Path) -> None:
54+
with patch("qodev_gitlab_cli.commands.install.console") as mock_console, \
55+
patch("qodev_gitlab_cli.commands.install.Path") as mock_path:
56+
mock_path.cwd.return_value = tmp_path
57+
install(skills=True)
58+
5359
calls = [str(c) for c in mock_console.print.call_args_list]
54-
assert any("--skills" in c for c in calls)
60+
assert any("Installed skills" in c for c in calls)

0 commit comments

Comments
 (0)