Skip to content

feat: support single dash as option value for long option - #472

Merged
shadowspawn merged 1 commit into
yargs:23.x.xfrom
shadowspawn:feature/dash-with-long-option
Oct 10, 2026
Merged

shadowspawn merged 1 commit into
yargs:23.x.xfrom
shadowspawn:feature/dash-with-long-option

Conversation

@shadowspawn

@shadowspawn shadowspawn commented Mar 4, 2023 •

Copy link
Copy Markdown
Member

There is a popular issue against yargs asking about using single dash for stdin. In fact this is already implemented and tested in yargs-parser for short options and positionals, and just needed a small tweak to work with long options.

yargs/yargs#1312

@shadowspawn
shadowspawn force-pushed the feature/dash-with-long-option branch from 3d763e0 to 877c819 Compare April 15, 2023 02:17
@shadowspawn
shadowspawn marked this pull request as ready for review April 15, 2023 02:20
@shadowspawn

Copy link
Copy Markdown
Member Author

(Rebased on top of main. CI broken by dependency changes unrelated to this PR: #470 and #478.)

@shadowspawn
shadowspawn force-pushed the feature/dash-with-long-option branch from 877c819 to b1a0d98 Compare August 15, 2025 02:54
@shadowspawn

Copy link
Copy Markdown
Member Author

Manually rebased onto esm-only code

@shadowspawn
shadowspawn changed the base branch from main to 23.x.x October 10, 2026 21:42
@shadowspawn
shadowspawn merged commit c03564b into yargs:23.x.x Oct 10, 2026
8 checks passed
@shadowspawn
shadowspawn deleted the feature/dash-with-long-option branch October 10, 2026 21:45
OrKoN added a commit to ChromeDevTools/chrome-devtools-mcp that referenced this pull request Oct 14, 2026
`chrome-devtools fill 1 <uid> -` reported success but cleared the field,
`type_text 1 -` typed an empty string, and values like `--weird` could
not be passed at all, not even after `--`.

yargs re-parses command positionals as `--name value` pairs. In that
pass yargs-parser treats any value starting with `-` (other than a
negative number) as the next flag and substitutes the string default
`''`. yargs also never fills positionals from the tokens after `--`.
Neither can be fixed via configuration (`unknown-options-as-args` and
`nargs` hit the same re-parse), and the upstream fix for the lone `-`
(yargs/yargs-parser#472) is unreleased and only covers that one case.

The CLI now shields such tokens before yargs sees them: a lone `-` is
always shielded, and everything after the first `--` is shielded with
the separator dropped. Shielded tokens are replaced by opaque
placeholders and restored when building the tool arguments. Unknown
flags such as `--weird` or `--pageid` without `--` are still rejected
by strict mode; the error tip and docs/cli.md now explain the `--` form.

Related upstream issues:
- yargs/yargs#1312
- yargs/yargs#1821
- yargs/yargs-parser#472

Fixes #2984
OrKoN added a commit to ChromeDevTools/chrome-devtools-mcp that referenced this pull request Oct 14, 2026
`chrome-devtools fill 1 <uid> -` reported success but cleared the field,
`type_text 1 -` typed an empty string, and values like `--weird` could
not be passed at all, not even after `--`.

yargs re-parses command positionals as `--name value` pairs. In that
pass yargs-parser treats any value starting with `-` (other than a
negative number) as the next flag and substitutes the string default
`''`. yargs also never fills positionals from the tokens after `--`.
Neither can be fixed via configuration (`unknown-options-as-args` and
`nargs` hit the same re-parse), and the upstream fix for the lone `-`
(yargs/yargs-parser#472) is unreleased and only covers that one case.

The CLI now shields such tokens before yargs sees them: a lone `-` is
always shielded, and everything after the first `--` is shielded with
the separator dropped. Shielded tokens are replaced by opaque
placeholders and restored when building the tool arguments. Unknown
flags such as `--weird` or `--pageid` without `--` are still rejected
by strict mode; the error tip and docs/cli.md now explain the `--` form.

Related upstream issues:
- yargs/yargs#1312
- yargs/yargs#1821
- yargs/yargs-parser#472

Fixes #2984
OrKoN added a commit to ChromeDevTools/chrome-devtools-mcp that referenced this pull request Oct 14, 2026
`chrome-devtools fill 1 <uid> -` reported success but cleared the field,
`type_text 1 -` typed an empty string, and values like `--weird` could
not be passed at all, not even after `--`.

yargs re-parses command positionals as `--name value` pairs. In that
pass yargs-parser treats any value starting with `-` (other than a
negative number) as the next flag and substitutes the string default
`''`. yargs also never fills positionals from the tokens after `--`.
Neither can be fixed via configuration (`unknown-options-as-args` and
`nargs` hit the same re-parse), and the upstream fix for the lone `-`
(yargs/yargs-parser#472) is unreleased and only covers that one case.

The CLI now shields such tokens before yargs sees them: a lone `-` is
always shielded, and everything after the first `--` is shielded with
the separator dropped. Shielded tokens are replaced by opaque
placeholders and restored when building the tool arguments. Unknown
flags such as `--weird` or `--pageid` without `--` are still rejected
by strict mode; the error tip and docs/cli.md now explain the `--` form.

Related upstream issues:
- yargs/yargs#1312
- yargs/yargs#1821
- yargs/yargs-parser#472

Fixes #2984
OrKoN added a commit to ChromeDevTools/chrome-devtools-mcp that referenced this pull request Oct 14, 2026
`chrome-devtools fill 1 <uid> -` reported success but cleared the field,
`type_text 1 -` typed an empty string, and values like `--weird` could
not be passed at all, not even after `--`.

yargs re-parses command positionals as `--name value` pairs. In that
pass yargs-parser treats any value starting with `-` (other than a
negative number) as the next flag and substitutes the string default
`''`. yargs also never fills positionals from the tokens after `--`.
Neither can be fixed via configuration (`unknown-options-as-args` and
`nargs` hit the same re-parse), and the upstream fix for the lone `-`
(yargs/yargs-parser#472) is unreleased and only covers that one case.

The CLI now shields such tokens before yargs sees them: a lone `-` is
always shielded, and everything after the first `--` is shielded with
the separator dropped. Shielded tokens are replaced by opaque
placeholders and restored when building the tool arguments. Unknown
flags such as `--weird` or `--pageid` without `--` are still rejected
by strict mode; the error tip and docs/cli.md now explain the `--` form.

Related upstream issues:
- yargs/yargs#1312
- yargs/yargs#1821
- yargs/yargs-parser#472

Fixes #2984
OrKoN added a commit to ChromeDevTools/chrome-devtools-mcp that referenced this pull request Oct 14, 2026
`chrome-devtools fill 1 <uid> -` reported success but cleared the field,
`type_text 1 -` typed an empty string, and values like `--weird` could
not be passed at all, not even after `--`.

yargs re-parses command positionals as `--name value` pairs. In that
pass yargs-parser treats any value starting with `-` (other than a
negative number) as the next flag and substitutes the string default
`''`. yargs also never fills positionals from the tokens after `--`.
Neither can be fixed via configuration (`unknown-options-as-args` and
`nargs` hit the same re-parse), and the upstream fix for the lone `-`
(yargs/yargs-parser#472) is unreleased and only covers that one case.

The CLI now shields such tokens before yargs sees them: a lone `-` is
always shielded, and everything after the first `--` is shielded with
the separator dropped. Shielded tokens are replaced by opaque
placeholders and restored when building the tool arguments. Unknown
flags such as `--weird` or `--pageid` without `--` are still rejected
by strict mode; the error tip and docs/cli.md now explain the `--` form.

Related upstream issues:
- yargs/yargs#1312
- yargs/yargs#1821
- yargs/yargs-parser#472

Fixes #2984
zjdCander pushed a commit to zjdCander/chrome-devtools-mcp that referenced this pull request Oct 14, 2026
…hromeDevTools#3084)

`chrome-devtools fill 1 <uid> -` reported success but cleared the field,
`type_text 1 -` typed an empty string, and values like `--weird` could
not be passed at all, not even after `--`.

yargs re-parses command positionals as `--name value` pairs. In that
pass yargs-parser treats any value starting with `-` (other than a
negative number) as the next flag and substitutes the string default
`''`. yargs also never fills positionals from the tokens after `--`.
Neither can be fixed via configuration (`unknown-options-as-args` and
`nargs` hit the same re-parse), and the upstream fix for the lone `-`
(yargs/yargs-parser#472) is unreleased and only covers that one case.

The CLI now shields such tokens before yargs sees them: a lone `-` is
always shielded, and everything after the first `--` is shielded with
the separator dropped. Shielded tokens are replaced by opaque
placeholders and restored when building the tool arguments. Unknown
flags such as `--weird` or `--pageid` without `--` are still rejected by
strict mode; the error tip and docs/cli.md now explain the `--` form.

Related upstream issues:
- yargs/yargs#1312
- yargs/yargs#1821
- yargs/yargs-parser#472

Fixes ChromeDevTools#2984
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant