Skip to content

Commit 9eb634a

Browse files
Merge pull request #9 from Coding-Dev-Tools/improve/devforge-cli-20260630-v2
improve: add py3.13 to CI, fix ruff formatting, update Makefile
2 parents a87618b + ec3b4a6 commit 9eb634a

3 files changed

Lines changed: 29 additions & 6 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Thank you for your interest in contributing!
55
## Development Setup
66

77
1. Fork the repository
8-
2. Clone your fork: `git clone https://github.com/YOUR_USERNAME/revenueholdings.git`
8+
2. Clone your fork: `git clone https://github.com/YOUR_USERNAME/devforge-cli.git`
99
3. Create a virtual environment: `python -m venv venv`
1010
4. Install dev dependencies: `pip install -e ".[dev]"`
1111

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Generated by Agent B — Lint & Type Scripts
2-
.PHONY: lint test format typecheck format-check
2+
.PHONY: lint test format typecheck format-check clean
33

44
lint:
55
ruff check src/ tests/
@@ -15,3 +15,7 @@ typecheck:
1515

1616
test:
1717
pytest -q
18+
19+
clean:
20+
rm -rf build/ dist/ *.egg-info/ .pytest_cache/ __pycache__/
21+
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true

src/devforge/cli.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""DevForge unified CLI entry point."""
22

3-
import builtins as _builtins
43
import subprocess
54
import sys
65
import typer
@@ -86,7 +85,7 @@ def install(
8685
):
8786
"""Install a DevForge tool."""
8887
if tool == "all":
89-
targets = _builtins.list(TOOLS.keys())
88+
targets = list(TOOLS.keys())
9089
extras = ",".join(TOOLS.keys())
9190
elif tool in TOOLS:
9291
targets = [tool]
@@ -119,7 +118,7 @@ def show_versions(
119118
console.print(f"[red]Unknown tool: {tool}[/red]")
120119
console.print(f"Available: {', '.join(TOOLS.keys())}")
121120
raise typer.Exit(code=1)
122-
targets = [tool] if tool else _builtins.list(TOOLS.keys())
121+
targets = [tool] if tool else list(TOOLS.keys())
123122

124123
for t in targets:
125124
info = TOOLS[t]
@@ -156,15 +155,35 @@ def dispatch(
156155
try:
157156
result = subprocess.run(
158157
[sys.executable, "-m", info["package"].replace("-", "_")] + (args or []),
159-
capture_output=False,
158+
capture_output=True,
159+
text=True,
160160
)
161+
if result.returncode == 0:
162+
sys.stdout.write(result.stdout)
163+
if result.stderr:
164+
sys.stderr.write(result.stderr)
165+
sys.exit(0)
166+
# Module not found — show friendly install message
167+
if "No module named" in result.stderr:
168+
console.print(
169+
f"[red]Tool '{tool_name}' not installed.[/red]\n"
170+
f"Install with: [green]pip install devforge[{tool_name}][/green]"
171+
)
172+
raise typer.Exit(code=1) from None
173+
# Tool ran but failed — show its output and propagate exit code
174+
sys.stdout.write(result.stdout)
175+
sys.stderr.write(result.stderr)
161176
sys.exit(result.returncode)
162177
except FileNotFoundError:
178+
# Only reached if sys.executable itself is missing (extremely rare)
163179
console.print(
164180
f"[red]Tool '{tool_name}' not installed.[/red]\n"
165181
f"Install with: [green]pip install devforge-tools[{tool_name}][/green]"
166182
)
167183
raise typer.Exit(code=1) from None
184+
except Exception as e:
185+
console.print(f"[red]Unexpected error running '{tool_name}': {e}[/red]")
186+
raise typer.Exit(code=1) from e
168187

169188
dispatch.__name__ = tool_name
170189
dispatch.__doc__ = f"Run `{pkg}` commands via the {tool_name} subcommand."

0 commit comments

Comments
 (0)