refactor: unify health/metrics/security registration via registerScanCommand#62
Merged
Merged
Conversation
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>
cdfda4b to
db8328e
Compare
There was a problem hiding this comment.
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 intoScanActionOptions. - Centralized the shared scan-command option plumbing, including the raw-argv fallback for
--branch/-band--max-files/-mcollisions 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 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, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: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/-mflags that collide with the root command. The three*ActionOptionsinterfaces collapse into oneScanActionOptions.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,
--helpoutput, and option parsing are all unchanged. This is a pure internal refactor.Verification
cli-option-routingunit test ✓health/metrics/securitycommand unit suites (30 tests) ✓health/metrics/securityE2E suites (11 tests, real CLI:--json,--checkgates,--max-filesrouting,--branch) ✓--helpoutput for all three commands manually confirmed identical🤖 Generated with Claude Code