refactor(cli): bucket per-command --help by moving cross-cutting flags off global#505
refactor(cli): bucket per-command --help by moving cross-cutting flags off global#505
Conversation
Greptile SummaryThis PR refactors the CLI flag surface by moving lockfile, network/fetch, and virtual-store flags from
Confidence Score: 4/5Safe to merge modulo the combined -rF short-flag gap in the argv rewriter, which is a regression for a documented usage pattern One confirmed P1 regression: aube -rF --frozen-lockfile breaks post-merge. All per-command install_overrides() wiring looks correct, scoped_registry_override removal is properly replaced, and tests cover happy paths. Score capped at 4 by the P1. crates/aube/src/main.rs — lift_per_subcommand_flags short-flag handling block (lines ~458–487) Important Files Changed
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 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 6b997f0. Configure here.
…s off global Every subcommand's --help used to show 30+ alphabetically interleaved flags because lockfile, network, and virtual-store options were declared `global = true` on the top-level Cli. The signal-to-noise ratio on `aube ls --help` was the chief complaint in #345. This change pulls three groups (LockfileArgs, NetworkArgs, VirtualStoreArgs) into `crates/aube/src/cli_args.rs`, each with `next_help_heading`, and flattens them only into the commands that actually consume them (install-trigger paths, network-touching paths, and auto-installers like `run`/`exec`). The pnpm-compat noops (`--workspace-packages`, `--ignore-workspace`, `--include-workspace-root`, `--aggregate-output`, `--stream`, `--use-stderr`, `--yes`) get `hide = true` — still parseable, just not in --help. Pre-subcommand placement (`aube --frozen-lockfile install`, `aube --registry=URL install`, …) keeps working through a small `lift_per_subcommand_flags` argv pre-pass that shifts moved-off-global flag tokens past the subcommand position before clap parses argv. Same trick we already use for `--config.<key>=<value>`. Workspace selection (`-F`, `-r`, `--filter-prod`, `--workspace-root`, `--fail-if-no-match`) stays on Cli — `aube -r run build` muscle memory is load-bearing for pnpm users and the cost/benefit of moving it doesn't justify the per-command flatten. The cli_ordering test gets a heading-aware variant: long-only flags must sort within each help-heading bucket rather than across the whole flat namespace. Closes #345 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mechanical regen via `mise run render` after the per-command flag move. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- aube add -g --registry=URL silently dropped --registry: run_global_inner built a throwaway AddArgs with NetworkArgs::default(), and the inner run()'s install_overrides() then RwLock-overwrote the registry slot the outer run() had just set. Lockfile/virtual-store didn't have the same bug because their slots are OnceLock-backed and idempotent. Plumb the caller's three flag groups through run_global -> run_global_inner so the inner overrides are no-op resets. - aube recursive --registry=URL install failed clap parsing on the rebuilt argv: lift_per_subcommand_flags ran on the outer argv only, not on the argv reconstructed by recursive::argv. Apply the same lift to nested_argv before Cli::try_parse_from. - test/cli.bats "aube parses pnpm global workspace/output flags" still asserted --workspace-packages / --aggregate-output / --use-stderr appear in `aube --help`; we deliberately hid those. Retarget the test to verify they parse silently while keeping the visible-flag assertions for --dir / --filter-prod / --workspace-root. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…to dlx - Lifter consumed flag-shaped tokens as kept-flag values: `aube --dir --frozen-lockfile install` would silently drop `--frozen-lockfile` because the rewriter ate it as the value of `--dir`. Same problem for the lifted-flag value path (`--registry --frozen-lockfile`). Add a `token_looks_like_flag` peek that gates value-consumption on whether the next token looks like another flag. Cursor Bugbot flagged this. - Drop the redundant `rest.is_empty()` arm after `s == "-"` already caught the bare-dash case earlier in the loop. Cursor Bugbot dead-code flag. - `aube dlx --enable-gvs <pkg>` regressed: dlx uses `trailing_var_arg + allow_hyphen_values`, so flags after the subcommand get swallowed into `params` unless declared on `DlxArgs`. Flatten LockfileArgs and VirtualStoreArgs alongside the existing NetworkArgs so all three groups parse before the trailing capture; bats `aube dlx accepts the global gvs override after the subcommand` (test/dlx.bats) was failing. Forward Default::default() through `create.rs`'s synthetic `DlxArgs` construction. - Add cli_spec_tests::lifter_does_not_eat_lifted_flag_as_kept_flag_value regression test. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6b997f0 to
17cd38d
Compare

Summary
--frozen-lockfile/--no-frozen-lockfile/--prefer-frozen-lockfile,--registry+--fetch-*, and--disable/--enable-global-virtual-storeoffglobal = trueand into per-commandArgsgroups (crates/aube/src/cli_args.rs) withnext_help_headingdirectives. They now appear only on commands that consume them, under a "Lockfile" / "Network" / "Virtual store" heading.--workspace-packages,--ignore-workspace,--include-workspace-root,--aggregate-output,--stream,--use-stderr,--yes) — still parseable, no longer cluttering--help.aube --frozen-lockfile install,aube --registry=URL install, etc.) via a smalllift_per_subcommand_flagsargv pre-pass that shifts the moved-off-global flag tokens past the subcommand position before clap sees argv. Mirrors the existingextract_config_overridesrewriter.-F/-r/--filter-prod/--workspace-root/--fail-if-no-match) deliberately stays onCli.aube -r run buildmuscle memory is load-bearing and the per-command move would have touched ~15 more command files for a smaller win.Result
Before,
aube ls --helpshowed ~30 alphabetically-interleaved flags including registry tuning, lockfile policy, retry timeouts, and pnpm-compat shims. After:```
$ aube install --help
…
Lockfile:
--frozen-lockfile
--no-frozen-lockfile
--prefer-frozen-lockfile
Network:
--fetch-retries
--fetch-retry-factor
--fetch-retry-maxtimeout
--fetch-retry-mintimeout
--fetch-timeout
--registry
Virtual store:
--disable-global-virtual-store
--enable-global-virtual-store
```
aube ls --helpno longer shows any of those — list doesn't flatten the install-trigger groups.Caveat
Implicit-script invocations like
aube --frozen-lockfile dev(wheredevis apackage.jsonscript) no longer behave the same: the rewriter now lifts--frozen-lockfilepastdevand clap'sExternalcatch-all captures it as a script arg. Users should writeaube run --frozen-lockfile devinstead. Documented in the rewriter's docstring.Test plan
cargo buildcargo clippy --all-targets -- -D warningscargo fmt --checkcargo test(all 399 unit + integration tests pass, including a newpre_subcommand_registry_lifts_to_installcovering the rewriter)aube install --help,aube ls --helpinspectionmise run test:bats) — runs in CICloses #345
Note
Medium Risk
Touches CLI argument parsing and adds an argv-rewrite pre-pass, so regressions could cause flags to be misrouted or no longer accepted in some invocation forms (especially pre-subcommand and implicit-script cases). No core install/registry logic changes beyond how overrides are plumbed in.
Overview
Refactors the CLI flag surface so cross-cutting options (lockfile policy, registry/fetch tuning, and global-virtual-store toggles) are defined as reusable
clap::Argsgroups incli_args.rsand flattened only into commands that actually consume them, keeping per-command--helpfocused.Adds a
lift_per_subcommand_flagsargv pre-pass inmain.rsto keepaube --registry=... <cmd>/aube --frozen-lockfile <cmd>working after those flags moved offglobal=true, and updates affected commands to call the newinstall_overrides()wiring for registry/fetch/lockfile/virtual-store overrides.Hides several pnpm-compatibility/no-op flags (e.g.
--aggregate-output,--stream,--use-stderr,--yes, and workspace-compat toggles) so they remain parseable but no longer clutter help output, and removes the old scoped registry override guard in favor of the new override plumbing.Reviewed by Cursor Bugbot for commit 17cd38d. Bugbot is set up for automated code reviews on this repo. Configure here.