@vmz/commander 0.3.12 → 0.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -617,6 +617,9 @@ function parseArgvCore(argv, optionDefs, strict) {
|
|
|
617
617
|
const rest = [];
|
|
618
618
|
/** Options explicitly supplied on the command line (defaults are not "used"). */
|
|
619
619
|
const used = new Set();
|
|
620
|
+
// 裸 `-` 是 stdout/stdin 约定值,不是选项标记:`--out -` 与 `--out=-` 等价。
|
|
621
|
+
// `--out --other` / `--out -x` 仍按缺值处理,后续真实选项不会被吞成值。
|
|
622
|
+
const isOptionToken = (token) => token.length > 1 && token.startsWith('-');
|
|
620
623
|
const handleMissing = (flagName) => {
|
|
621
624
|
if (strict) {
|
|
622
625
|
throw CliError.parseError('commander::missing_option_value', { option: flagName });
|
|
@@ -659,7 +662,7 @@ function parseArgvCore(argv, optionDefs, strict) {
|
|
|
659
662
|
}
|
|
660
663
|
else {
|
|
661
664
|
const next = argv[i + 1];
|
|
662
|
-
if (next != null && !next
|
|
665
|
+
if (next != null && !isOptionToken(next)) {
|
|
663
666
|
assignOption(options, def, used, next);
|
|
664
667
|
i += 1;
|
|
665
668
|
}
|
|
@@ -689,7 +692,7 @@ function parseArgvCore(argv, optionDefs, strict) {
|
|
|
689
692
|
}
|
|
690
693
|
if (def.takesValue) {
|
|
691
694
|
const next = argv[i + 1];
|
|
692
|
-
if (next != null && !next
|
|
695
|
+
if (next != null && !isOptionToken(next)) {
|
|
693
696
|
assignOption(options, def, used, next);
|
|
694
697
|
i += 1;
|
|
695
698
|
}
|
package/package.json
CHANGED