feat(cli): align CLI with clig.dev and 12-factor guidelines#623
Merged
Conversation
- add `--color` / `--no-color` plus `REACT_DOCTOR_NO_COLOR` / `REACT_DOCTOR_FORCE_COLOR` env overrides, resolved before parse so the choice reaches all output - lead `--help` (root + install) with worked examples and a feedback link - add a `version` subcommand (version + node + platform) and a `-V` alias - make `help` / `help <command>` show help instead of scanning a directory named "help" Co-authored-by: Cursor <cursoragent@cursor.com>
… help) Co-authored-by: Cursor <cursoragent@cursor.com>
commit: |
Contributor
|
React Doctor found 18 files changed in this pull request, but none matched the files covered by its enabled checks. Scope: 18 files changed on Generated by React Doctor. Questions? Contact founders@million.dev. |
Address review findings: - resolve `--color`/`--no-color` from the stripped argv before help normalization drops trailing tokens, so `react-doctor help --no-color` is respected - register a `version` flag spec and add `--color`/`--no-color` options to the `version` command so `react-doctor version --no-color` no longer aborts with an unknown-option error Co-authored-by: Cursor <cursoragent@cursor.com>
Address a second review round: - `-V` no longer misfires when passed as an option value (e.g. `--cwd -V`); a standalone `-V` is the only form `stripUnknownCliFlags` drops, so "in raw argv but stripped out" distinguishes flag from value - `help <flag> <command>` now resolves the subcommand past intervening flags (first non-flag token after `help`) - mirror the resolved color choice onto `NO_COLOR` / `FORCE_COLOR` so the `ora` spinner and `prompts` honor `--no-color` / `--color` too, not just the picocolors-based report highlighter Co-authored-by: Cursor <cursoragent@cursor.com>
`--no-score` already disables the score API, the share URL, and (since crash reporting landed) Sentry, so expose that opt-out under the clearer `--no-telemetry` name. Both resolve to `noScore` and gate crash reporting off via the raw-argv check in instrument.ts. Co-authored-by: Cursor <cursoragent@cursor.com>
The previous commit accidentally overwrote the existing CI-behavior (#302) and warnings/--fail-on tests while adding the --no-telemetry case. Restore them alongside the new alias test. Co-authored-by: Cursor <cursoragent@cursor.com>
`--score` (score-only output) combined with `--no-telemetry` (skip scoring) previously printed a confusing "Score disabled" line in score-only mode. Validate it up front with a clear error, matching the existing mutual-exclusion checks. Co-authored-by: Cursor <cursoragent@cursor.com>
Member
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit a931264. Configure here.
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.
Why
Bring the
react-doctorCLI in line with the clig.dev and 12-factor CLI Apps guidelines. Three concrete gaps:helpwas broken —react-doctor helptried to scan a directory namedhelpand errored.NO_COLOR/TTY, but there was no--color/--no-coloroverride or app-specific env toggle.-v/--version; noversionsubcommand, no-V, and--helphad zero examples (clig.dev's top Help guideline is "lead with examples").Before:
After:
What changed
--color/--no-colorflags plus app-specificREACT_DOCTOR_NO_COLOR/REACT_DOCTOR_FORCE_COLORenv vars, resolved before Commander parses so the choice reaches every surface (scan report, branded header, score, prompts, errors). Flags win over env vars, which win over picocolors' built-inNO_COLOR/FORCE_COLOR/TERM/TTY detection. Backed by a new@react-doctor/coresetColorEnabled()toggle.install--helpnow open with alignedExamples:blocks and a "Feedback & bug reports" link (rendered lazily so they honor the color preference).versionsubcommand +-V—react-doctor versionprints version + Node + platform for debugging;-v/-V/--versionstay terse for scripts.help/help <command>— normalized in the bootstrap to the existing--helppaths instead of being swallowed by the default scan action.NODE_ARGUMENT_COUNTargv constant intoconstants.ts.Eval results
Not applicable — this is a CLI/UX change, not a lint rule, so the RDE rule-eval harness was not run.
Test plan
pnpm --filter react-doctor exec vp test run tests/(1453 passed)apply-color-preference,normalize-help-command,version-command, extendedstrip-unknown-cli-flagspnpm --filter react-doctor typecheckpnpm exec vp lint(changed files) +pnpm exec vp fmt --checkpnpm smoke:json-reporthelp,help install,version,-v/-V/--version,--color/--no-color(ANSI on/off verified when piped),REACT_DOCTOR_FORCE_COLOR=1Made with Cursor
Note
Low Risk
Changes are limited to CLI bootstrap, help text, and output coloring; telemetry opt-out extends existing --no-score behavior without altering scan logic.
Overview
Aligns the react-doctor CLI with clig.dev / 12-factor UX: explicit color control, fixed help routing, richer version output, and clearer opt-out wording for score/telemetry.
Color — Adds
--color/--no-coloron the default scan,install, andversionflows, plusREACT_DOCTOR_FORCE_COLOR/REACT_DOCTOR_NO_COLOR. Preference is resolved from stripped argv before Commander runs (so help epilogs respect it), updates the sharedhighlightervia newsetColorEnabled()in@react-doctor/core, and mirrors the choice ontoFORCE_COLOR/NO_COLORfor spinners and prompts. Last flag wins; tokens after--are ignored.Help — Rewrites leading
help/help <command>to--help/<command> --helpso users no longer scan a directory namedhelp. Root andinstallhelp now lead with example commands (lazy epilog renderers) and add a feedback/issues link.Version — New
react-doctor versionprintsreact-doctor/<ver> <platform>-<arch> node-<node>; standalone-Vprints the bare version before parse (alongside existing-v/--version).Telemetry alias —
--no-telemetryaliases--no-score(score API, share URL, Sentry); inspect resolution and early Sentry init honor it;--score+--no-telemetryis rejected. Flag stripper knows the new flags andversionsubcommand spec.Reviewed by Cursor Bugbot for commit a931264. Bugbot is set up for automated code reviews on this repo. Configure here.