Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(restyle): raise a usage error for an unknown style argument (#908)

Raghav Chamadiyac8f3671e5fd0
diff --git a/packages/cli/src/repowise/cli/commands/restyle_cmd.py b/packages/cli/src/repowise/cli/commands/restyle_cmd.py
index 54ee4076d..7b3037b1f 100644
--- a/packages/cli/src/repowise/cli/commands/restyle_cmd.py
+++ b/packages/cli/src/repowise/cli/commands/restyle_cmd.py
@@ -179,7 +179,10 @@ def restyle_command(
style = style.strip().lower()
if not is_known_style(style, repo_path):
valid = ", ".join(s.name for s in list_styles(repo_path))
- raise click.ClickException(f"Unknown style '{style}'. Choose one of: {valid}.")
+ # An unknown STYLE is a mis-typed argument, not a product failure:
+ # BadArgumentUsage renders the usage hint and (via the telemetry
+ # classifier) records as a usage_error rather than an error.
+ raise click.BadArgumentUsage(f"Unknown style '{style}'. Choose one of: {valid}.")
# Restyle only makes sense for a full index (one that has generated docs).
if not state:
diff --git a/tests/unit/cli/test_restyle_cmd.py b/tests/unit/cli/test_restyle_cmd.py
index c77f5e526..3c9b688bd 100644
--- a/tests/unit/cli/test_restyle_cmd.py
+++ b/tests/unit/cli/test_restyle_cmd.py
@@ -60,7 +60,9 @@ def test_restyle_no_style_shows_current_and_options():
def test_restyle_unknown_style_errors(tmp_path):
result = CliRunner().invoke(cli, ["restyle", "bogus", str(tmp_path)])
- assert result.exit_code == 1
+ # A mistyped STYLE is a usage error (Click convention: exit code 2), not a
+ # generic failure — see the telemetry usage_error classification.
+ assert result.exit_code == 2
assert "Unknown style" in result.output
assert "comprehensive" in result.output # lists valid choices