@optique/core 1.3.6 → 1.3.7-dev.3001

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.
@@ -1803,16 +1803,29 @@ function command(name, parser, options = {}) {
1803
1803
  * // mycli --debug --foo bar
1804
1804
  * // → { debug: true, extra: ["--foo", "bar"] }
1805
1805
  *
1806
- * // greedy format: captures all remaining tokens
1807
- * const parser = command("exec", object({
1808
- * container: argument(string()),
1809
- * args: passThrough({ format: "greedy" }),
1810
- * }));
1806
+ * // greedy format: require a program name before capturing the rest
1807
+ * const parser = command("exec", map(
1808
+ * seq(
1809
+ * argument(string({ metavar: "PROGRAM" })),
1810
+ * passThrough({ format: "greedy" }),
1811
+ * ),
1812
+ * ([program, args]) => ({ program, args }),
1813
+ * ));
1811
1814
  *
1812
- * // myproxy exec mycontainer --verbose -it bash
1813
- * // → { container: "mycontainer", args: ["--verbose", "-it", "bash"] }
1815
+ * // myproxy exec my-program --help
1816
+ * // → { program: "my-program", args: ["--help"] }
1814
1817
  * ```
1815
1818
  *
1819
+ * With built-in help enabled, `myproxy exec --help` displays help because `seq()`
1820
+ * does not reach pass-through until the program name is parsed. After the
1821
+ * program name, greedy capture can consume remaining tokens, including
1822
+ * `--help`, so they can be forwarded. Putting this parser last in an `object()`
1823
+ * does not establish the same boundary: fields are tried by priority, not
1824
+ * declaration order.
1825
+ * An immediate `--` after the program name is consumed by `seq()` as an
1826
+ * options terminator before greedy capture starts. Once capture starts,
1827
+ * subsequent `--` tokens are kept.
1828
+ *
1816
1829
  * @since 0.8.0
1817
1830
  */
1818
1831
  function passThrough(options = {}) {
@@ -584,16 +584,29 @@ interface PassThroughOptions {
584
584
  * // mycli --debug --foo bar
585
585
  * // → { debug: true, extra: ["--foo", "bar"] }
586
586
  *
587
- * // greedy format: captures all remaining tokens
588
- * const parser = command("exec", object({
589
- * container: argument(string()),
590
- * args: passThrough({ format: "greedy" }),
591
- * }));
587
+ * // greedy format: require a program name before capturing the rest
588
+ * const parser = command("exec", map(
589
+ * seq(
590
+ * argument(string({ metavar: "PROGRAM" })),
591
+ * passThrough({ format: "greedy" }),
592
+ * ),
593
+ * ([program, args]) => ({ program, args }),
594
+ * ));
592
595
  *
593
- * // myproxy exec mycontainer --verbose -it bash
594
- * // → { container: "mycontainer", args: ["--verbose", "-it", "bash"] }
596
+ * // myproxy exec my-program --help
597
+ * // → { program: "my-program", args: ["--help"] }
595
598
  * ```
596
599
  *
600
+ * With built-in help enabled, `myproxy exec --help` displays help because `seq()`
601
+ * does not reach pass-through until the program name is parsed. After the
602
+ * program name, greedy capture can consume remaining tokens, including
603
+ * `--help`, so they can be forwarded. Putting this parser last in an `object()`
604
+ * does not establish the same boundary: fields are tried by priority, not
605
+ * declaration order.
606
+ * An immediate `--` after the program name is consumed by `seq()` as an
607
+ * options terminator before greedy capture starts. Once capture starts,
608
+ * subsequent `--` tokens are kept.
609
+ *
597
610
  * @since 0.8.0
598
611
  */
599
612
  declare function passThrough(options?: PassThroughOptions): FluentParser<"sync", readonly string[], readonly string[]>;
@@ -584,16 +584,29 @@ interface PassThroughOptions {
584
584
  * // mycli --debug --foo bar
585
585
  * // → { debug: true, extra: ["--foo", "bar"] }
586
586
  *
587
- * // greedy format: captures all remaining tokens
588
- * const parser = command("exec", object({
589
- * container: argument(string()),
590
- * args: passThrough({ format: "greedy" }),
591
- * }));
587
+ * // greedy format: require a program name before capturing the rest
588
+ * const parser = command("exec", map(
589
+ * seq(
590
+ * argument(string({ metavar: "PROGRAM" })),
591
+ * passThrough({ format: "greedy" }),
592
+ * ),
593
+ * ([program, args]) => ({ program, args }),
594
+ * ));
592
595
  *
593
- * // myproxy exec mycontainer --verbose -it bash
594
- * // → { container: "mycontainer", args: ["--verbose", "-it", "bash"] }
596
+ * // myproxy exec my-program --help
597
+ * // → { program: "my-program", args: ["--help"] }
595
598
  * ```
596
599
  *
600
+ * With built-in help enabled, `myproxy exec --help` displays help because `seq()`
601
+ * does not reach pass-through until the program name is parsed. After the
602
+ * program name, greedy capture can consume remaining tokens, including
603
+ * `--help`, so they can be forwarded. Putting this parser last in an `object()`
604
+ * does not establish the same boundary: fields are tried by priority, not
605
+ * declaration order.
606
+ * An immediate `--` after the program name is consumed by `seq()` as an
607
+ * options terminator before greedy capture starts. Once capture starts,
608
+ * subsequent `--` tokens are kept.
609
+ *
597
610
  * @since 0.8.0
598
611
  */
599
612
  declare function passThrough(options?: PassThroughOptions): FluentParser<"sync", readonly string[], readonly string[]>;
@@ -1803,16 +1803,29 @@ function command(name, parser, options = {}) {
1803
1803
  * // mycli --debug --foo bar
1804
1804
  * // → { debug: true, extra: ["--foo", "bar"] }
1805
1805
  *
1806
- * // greedy format: captures all remaining tokens
1807
- * const parser = command("exec", object({
1808
- * container: argument(string()),
1809
- * args: passThrough({ format: "greedy" }),
1810
- * }));
1806
+ * // greedy format: require a program name before capturing the rest
1807
+ * const parser = command("exec", map(
1808
+ * seq(
1809
+ * argument(string({ metavar: "PROGRAM" })),
1810
+ * passThrough({ format: "greedy" }),
1811
+ * ),
1812
+ * ([program, args]) => ({ program, args }),
1813
+ * ));
1811
1814
  *
1812
- * // myproxy exec mycontainer --verbose -it bash
1813
- * // → { container: "mycontainer", args: ["--verbose", "-it", "bash"] }
1815
+ * // myproxy exec my-program --help
1816
+ * // → { program: "my-program", args: ["--help"] }
1814
1817
  * ```
1815
1818
  *
1819
+ * With built-in help enabled, `myproxy exec --help` displays help because `seq()`
1820
+ * does not reach pass-through until the program name is parsed. After the
1821
+ * program name, greedy capture can consume remaining tokens, including
1822
+ * `--help`, so they can be forwarded. Putting this parser last in an `object()`
1823
+ * does not establish the same boundary: fields are tried by priority, not
1824
+ * declaration order.
1825
+ * An immediate `--` after the program name is consumed by `seq()` as an
1826
+ * options terminator before greedy capture starts. Once capture starts,
1827
+ * subsequent `--` tokens are kept.
1828
+ *
1816
1829
  * @since 0.8.0
1817
1830
  */
1818
1831
  function passThrough(options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.3.6",
3
+ "version": "1.3.7-dev.3001",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",
@@ -237,7 +237,7 @@
237
237
  },
238
238
  "sideEffects": false,
239
239
  "devDependencies": {
240
- "@optique/env": "1.3.6",
240
+ "@optique/env": "1.3.7-dev.3001+a1175c5b",
241
241
  "@types/node": "^24.0.0",
242
242
  "fast-check": "^4.7.0",
243
243
  "tsdown": "^0.13.0",
@@ -243,8 +243,8 @@ Common mistakes checklist
243
243
  `withDefault(..., false)` for ordinary optional flags.
244
244
  - Do not expect `multiple(p)` to fail when absent; it returns `[]`. Wrap with
245
245
  `nonEmpty()` when at least one value is required.
246
- - Do not confuse free-order parsing with `seq()`. Most constructs let child
247
- parsers compete by priority; use `seq()` only for truly ordered grammars.
246
+ - For ordered grammars, use `seq()`; `object()` fields compete by priority.
247
+ In wrappers, require the program name before greedy `passThrough()`.
248
248
  - Do not concatenate plain strings for errors or descriptions. Use structured
249
249
  `message` values.
250
250
  - Register contexts for `bindEnv()`, `bindConfig()`, `bindDerivedDefault()`,