feat(cli): hoist global flags from any argv position and add -v alias#709
feat(cli): hoist global flags from any argv position and add -v alias#709
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Docs
Other
Bug Fixes 🐛Dashboard
Other
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
|
Codecov Results 📊✅ 134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1570 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.30% 95.33% +0.03%
==========================================
Files 230 232 +2
Lines 33501 33632 +131
Branches 0 0 —
==========================================
+ Hits 31928 32062 +134
- Misses 1573 1570 -3
- Partials 0 0 —Generated by Codecov Action |
fca1b1b to
a3181cf
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a3181cf. Configure here.
Global flags (--verbose, --json, --log-level, --fields) only worked when placed after the leaf command because Stricli parses flags at the leaf level only. This adds an argv preprocessor that relocates these flags from any position to the end of argv before Stricli processes it, allowing patterns like `sentry --verbose issue list` and `sentry cli -v upgrade`. Also injects -v as a short alias for --verbose on all leaf commands, following the existing buildDeleteCommand alias injection pattern.
a3181cf to
57aacfd
Compare

Summary
--verbose,-v,--json,--log-level,--fields) from any position to the end of argv before Stricli processes it-vas a short alias for--verboseon all leaf commandssentry --verbose issue list,sentry cli -v upgrade, etc.Problem
Stricli only parses flags at the leaf command level. Global flags injected by
buildCommandfail when placed before subcommands:sentry cli upgrade --verbose✅ workedsentry cli --verbose upgrade❌ Stricli can't route past the flagsentry --verbose cli upgrade❌ samesentry cli upgrade -v❌ no short alias existedApproach
src/lib/argv-hoist.ts— Pure function (zero imports, zero side effects) that scans argv left-to-right and relocates known global flags to the tail. Respects--separator, handles--flag=valueand--no-flagforms, and preserves relative order of all tokens.src/lib/command.ts— Injectsv: "verbose"alias following the existingbuildDeleteCommandpattern. Skipped when command owns--verboseorvis already taken.src/cli.ts— CallshoistGlobalFlags()insiderunCli(). OriginalcliArgspreserved for help-as-positional recovery (cliArgs.at(-1) === "help"); hoisted args passed to executor.Tests
command.test.tspasses (81 tests total)