fix: forward extra arguments to devbox run scenarios#47
Conversation
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe ChangesRun command argument handling
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as newRunCmd (Cobra)
participant Splitter as splitScenarioArgs
participant Runner as runRun
User->>CLI: devbox run e2e -- --tag
CLI->>Splitter: splitScenarioArgs(args)
Splitter-->>CLI: scenario="e2e", passthrough=["--tag"]
CLI->>Runner: runRun(ctx, p, scenario, passthrough, noTty)
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Why
devbox run <scenario> [args...]is documented to forward extra arguments to the scenario's command (docs/run.mdshowsdevbox run test --verbose --suite=api), but today any extra argument makes the command fail before the scenario ever runs. Bothdevbox run e2e --tag fooanddevbox run e2e -- --tag fooerror out withaccepts 1 arg(s), received N.The cause is two lines that contradict each other:
Args: cobra.ExactArgs(1)rejects any argv beyond the scenario name, which silently defeats theSetInterspersed(false)that exists specifically to enable pass-through.What
cobra.ExactArgs(1)→cobra.MinimumNArgs(1). A scenario name is still required; extra args are now accepted.SetInterspersed(false)so the flag-only form (run e2e --tag foo, no--) works and tokens after the scenario name are forwarded rather than swallowed by devbox's own flags.--from the forwarded args so bothrun e2e --tag fooandrun e2e -- --tag fooforward a clean[--tag foo]— matching the docker/cargo/npm separator convention. A--appearing later is passed through untouched.docs/run.md.Notes
runcommand changes.shell.goalso usesExactArgs(1), but that is correct —shelltakes exactly one service name with no pass-through — so it is left alone.newRunCmd()so the regression tests bind to the real command object (real validator +SetInterspersed(false)) rather than a hand-rebuilt copy that could drift. The contract test is what guards against a future revert toExactArgs.---separated, single-arg, and no-scenario cases.Summary by CodeRabbit
devbox runnow accepts flexible argument passing, making it easier to forward flags to scenarios.--is now treated as an explicit separator and won’t be passed through unexpectedly.devbox runargument format and forwarding behavior.