fix(cli): accept browser --window placed after the subcommand (#1850) - #1926
Closed
LeoLin990405 wants to merge 1 commit into
Closed
fix(cli): accept browser --window placed after the subcommand (#1850)#1926LeoLin990405 wants to merge 1 commit into
--window placed after the subcommand (#1850)#1926LeoLin990405 wants to merge 1 commit into
Conversation
`--window` is a `browser` parent-command option, so commander only accepted it before the leaf subcommand. The natural placement `opencli browser work open <url> --window background` failed with `error: unknown option '--window'` (jackwener#1850). rewriteBrowserArgv now hoists a trailing `--window <mode>` / `--window=<mode>` to the parent option slot (before the subcommand), so both placements parse the same. argv without `--window` is untouched. Tests: 4 new rewriteBrowserArgv cases (trailing form, `=` form, already-in-slot no-op, with `--profile`); `vitest run src/cli-argv-preprocess.test.ts` -> 32 passed. Verified live: `browser <session> open <url> --window background` now opens the page. Fixes jackwener#1850
Owner
|
Thanks for the focused fix. I compared this with #1899 because both PRs address #1850. I opened a replacement PR that uses your lower-blast approach as the core design: keep Replacement PR: #1963 I also credited you in the replacement commit as a co-author:
Main differences in #1963:
|
Contributor
Author
|
Makes sense — #1963 is the better version (nested-command coverage + the |
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.
What
opencli browser <session> <subcommand> ... --window <mode>fails witherror: unknown option '--window'(#1850).--windowis registered on thebrowserparent command, so commander only accepts it before the leaf subcommand:opencli browser work --window background open https://x.comopencli browser work open https://x.com --window background← the obvious placementFix
rewriteBrowserArgv(the existingbrowser <session> <subcommand>argv preprocessor) now hoists a trailing--window <mode>/--window=<mode>to the parent option slot, so both placements parse identically. argv without--windowis unchanged; only the first occurrence is hoisted; the scan stops at--.Tests / verification
rewriteBrowserArgvcases: trailing form,=form, already-in-slot no-op, and with a leading--profile.vitest run src/cli-argv-preprocess.test.ts→ 32 passed.opencli browser <session> open https://example.com --window backgroundnow opens the page (previously errored withunknown option '--window').Fixes #1850