Skip to content

refactor: unify health/metrics/security registration via registerScanCommand#62

Open
Arthur742Ramos wants to merge 1 commit into
mainfrom
arthur742ramos/refactor-scan-commands
Open

refactor: unify health/metrics/security registration via registerScanCommand#62
Arthur742Ramos wants to merge 1 commit into
mainfrom
arthur742ramos/refactor-scan-commands

Conversation

@Arthur742Ramos

Copy link
Copy Markdown
Owner

Summary

The three deterministic scan commands — bootcamp health, bootcamp metrics, bootcamp security — had grown into three ~28-line copy-pasted Commander registrations plus three byte-identical option interfaces, differing only in the command name, description, a few help strings, and the runner function.

This PR extracts a single registerScanCommand(...) helper:

registerScanCommand({
  name: "security",
  description: "...",
  checkHelp: "...",
  minScoreHelp: "...",
  jsonHelp: "...",
  run: runSecurityCommand,
});

The helper owns the shared flag surface (--branch, --check, --min-score, --json, --max-files, --keep-temp, --verbose) and the identical option plumbing — including the raw-argv fallback for the -b/-m flags that collide with the root command. The three *ActionOptions interfaces collapse into one ScanActionOptions.

Adding a future scan command is now a ~9-line config object instead of a 28-line copy-paste, and the three existing commands can no longer drift out of sync.

Behavior-preserving

Command names, descriptions, --help output, and option parsing are all unchanged. This is a pure internal refactor.

Verification

  • cli-option-routing unit test ✓
  • health / metrics / security command unit suites (30 tests) ✓
  • health / metrics / security E2E suites (11 tests, real CLI: --json, --check gates, --max-files routing, --branch) ✓
  • --help output for all three commands manually confirmed identical
  • Full suite green; typecheck + lint + build clean
  • Net −15 lines, and far less duplication

🤖 Generated with Claude Code

The three deterministic scan commands (`health`, `metrics`, `security`) had
diverged into three ~28-line copy-pasted Commander registrations plus three
byte-identical option interfaces — differing only in name, description, a few
help strings, and the runner function.

Extract a single `registerScanCommand({ name, description, checkHelp,
minScoreHelp, jsonHelp, run })` helper that owns the shared flag surface and
option plumbing (including the raw-argv fallback for the `-b`/`-m` flags that
collide with the root command). The three interfaces collapse to one
`ScanActionOptions`. Adding a future scan command is now a ~9-line config
object instead of a 28-line copy-paste.

Behavior-preserving: command names, descriptions, help text, and option
parsing are unchanged. Verified by the existing cli-routing unit test, the
three command unit suites, and the three E2E suites (11 tests) — all green,
plus full suite and unchanged `--help` output.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Arthur742Ramos Arthur742Ramos force-pushed the arthur742ramos/refactor-scan-commands branch from cdfda4b to db8328e Compare June 11, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants