Skip to content

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

Merged
Arthur742Ramos merged 1 commit into
mainfrom
arthur742ramos/refactor-scan-commands
Jun 15, 2026
Merged

refactor: unify health/metrics/security registration via registerScanCommand#62
Arthur742Ramos merged 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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the CLI registration for the deterministic scan commands (bootcamp health, bootcamp metrics, bootcamp security) by introducing a shared registerScanCommand(...) helper in src/cli.ts, reducing duplicated Commander wiring while keeping the command surface consistent.

Changes:

  • Collapsed the three near-identical Commander registrations into a single registerScanCommand(...) helper and unified the per-command action options into ScanActionOptions.
  • Centralized the shared scan-command option plumbing, including the raw-argv fallback for --branch/-b and --max-files/-m collisions with root options.
  • Documented the refactor in the changelog.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/cli.ts Extracts shared scan command registration and option handling into registerScanCommand(...).
CHANGELOG.md Notes the scan-command registration refactor as a behavior-preserving internal change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cli.ts
Comment on lines +225 to +235
const branch = opts.branch || getCliFlagValue(["--branch", "-b"]) || "";
const maxFiles = opts.maxFiles || getCliFlagValue(["--max-files", "-m"]) || "500";
await config.run(repoUrl, {
branch,
check: opts.check || false,
minScore: parseInt(opts.minScore || "70", 10),
json: opts.json || false,
maxFiles: parseInt(maxFiles, 10),
keepTemp: opts.keepTemp || false,
verbose: opts.verbose || false,
});
@Arthur742Ramos Arthur742Ramos merged commit 4265cf8 into main Jun 15, 2026
14 checks passed
@Arthur742Ramos Arthur742Ramos deleted the arthur742ramos/refactor-scan-commands branch June 15, 2026 19:49
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.

3 participants