GeezerVison is showing github.com — docs(spec): reframe the rendering corpus around the fleet, not one CLI · jdx/usage@a378716
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: conformance/src/render.rs +15-10Lines changed: 15 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 | //! emitter's help table), and three implementations of a rendering rule drift exactly the way | 7 | 7 | //! three implementations of a parsing rule do. | 8 | 8 | //! | 9 | | -//! # Why this exists beside the mise fixture | | 9 | +//! # Why this exists beside the fleet gate | 10 | 10 | //! | 11 | | -//! `benches/gate/tests/help.rs` compares every one of mise's 211 commands against usage-lib, | 12 | | -//! byte for byte, and it is the check that decides whether an adopter's help output changes. | 13 | | -//! What it cannot do is cover a shape mise does not use. A flag whose *value* is optional is | 14 | | -//! one: every flag value mise declares is required and undefaulted, so `[--opt [n]]` rendered | 15 | | -//! as `[--opt <n>]` for as long as usage-argv existed and the 211-command comparison passed | 16 | | -//! throughout. | | 11 | +//! `benches/gate/tests/help.rs` and `fleet.rs` beside it render every command of mise and the | | 12 | +//! six other jdx CLIs and compare each page against usage-lib byte for byte. That is the check | | 13 | +//! that decides whether an adopter's help output changes, and no hand-written corpus will match | | 14 | +//! it for scale. | 17 | 15 | //! | 18 | | -//! So the two are complements. The fixture answers "does a real CLI still render the same", | 19 | | -//! at a scale no hand-written case reaches. The corpus answers "does every shape a spec can | 20 | | -//! declare render the same", including the ones no single CLI happens to contain. | | 16 | +//! What it cannot do is cover a shape no CLI in the fleet uses. Across all 809 value-taking | | 17 | +//! flags in the fleet, three of the four "must the flag be given" against "must its value be | | 18 | +//! given" pairings appear and the fourth appears nowhere; nor does a flag whose value carries a | | 19 | +//! default, which relaxes the value's brackets by another route. The fleet was one CLI until | | 20 | +//! #972, and widening it found three bugs at once — so the lesson is not that seven is enough, | | 21 | +//! it is that a fixture only asks about the vocabulary its CLIs happen to use. | | 22 | +//! | | 23 | +//! So the two are complements. The gate answers "do real CLIs still render the same", at a scale | | 24 | +//! no hand-written case reaches. This answers "does every shape a spec can declare render the | | 25 | +//! same", including the ones no CLI in the fleet contains. | 21 | 26 | //! | 22 | 27 | //! # Scope | 23 | 28 | //! | |
Collapse file Copy file name to clipboardExpand all lines: conformance/src/tables.rs +6-4Lines changed: 6 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -273,10 +273,12 @@ fn flag_meta<'a>( | 273 | 273 | help: opt(&f.help), | 274 | 274 | long_help: opt(&f.help_long), | 275 | 275 | value_name: arg.map(|a| leak(&a.name)), | 276 | | - // The value's own bracket bit, folded with the value's own default the way usage-lib | 277 | | - // folds a positional's — a default declared on the *flag* is a different statement and | 278 | | - // stays in `default` below. | 279 | | - value_required: arg.is_none_or(|a| a.required && a.default.is_empty()), | | 276 | + // The value's own bracket bit, which is not the flag's — usage-lib renders a flag from | | 277 | + // two independent `required` bits and a spec can write either without the other. Folded | | 278 | + // with the value's own default the way usage-lib folds a positional's, so | | 279 | + // `arg "<n>" default="4"` inside a flag reads as optional; a default declared on the | | 280 | + // *flag* is a different statement and stays in `default` below. | | 281 | + value_optional: arg.is_some_and(|a| !a.required || !a.default.is_empty()), | 280 | 282 | env: opt(&f.env), | 281 | 283 | default: strs(&f.default), | 282 | 284 | choices: arg | |
Collapse file Copy file name to clipboardExpand all lines: corpus/render/01-flag-values.json +28-10Lines changed: 28 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | 2 | 2 | "section": "flag-values", | 3 | | - "about": "A flag and its value each carry brackets, and the two are decided separately. The flag's say whether the flag may be left out; the value's say whether a value must follow it. A spec can write either without the other, so there are four pairings and no CLI is likely to contain all four — mise contains exactly one, which is how `[--opt [n]]` rendered as `[--opt <n>]` in usage-argv while a 211-command comparison against usage-lib passed.", | | 3 | + "about": "A flag and its value each carry brackets, and the two are decided separately. The flag's say whether the flag may be left out; the value's say whether a value must follow it. A spec can write either without the other, so there are four pairings — and across all 809 value-taking flags in mise and the fleet, three appear and `<--jobs [n]>` appears nowhere, as does a value carrying a `default`. `[--opt [n]]` was itself rendered `[--opt <n>]` until #969, and pitchfork is the only reason that was visible; the two rows still at zero have nothing but these vectors holding them.", | 4 | 4 | "vectors": [ | 5 | 5 | { | 6 | 6 | "id": "flag-optional-value-required", | 7 | 7 | "doc": "The ordinary pairing: the flag may be left out, and a value must follow it if it is not.", | 8 | 8 | "spec": "name \"ex\"\nbin \"ex\"\nflag \"--tool <TOOL>\" help=\"Which tool\"\n", | 9 | | - "expect": { "usage": "ex [--tool <TOOL>]" } | | 9 | + "expect": { | | 10 | + "usage": "ex [--tool <TOOL>]" | | 11 | + } | 10 | 12 | }, | 11 | 13 | { | 12 | 14 | "id": "flag-required-value-required", | 13 | 15 | "doc": "Both required. The only pairing mise's spec contains.", | 14 | 16 | "spec": "name \"ex\"\nbin \"ex\"\nflag \"--v <n>\" required=#true help=\"How loud\"\n", | 15 | | - "expect": { "usage": "ex <--v <n>>" } | | 17 | + "expect": { | | 18 | + "usage": "ex <--v <n>>" | | 19 | + } | 16 | 20 | }, | 17 | 21 | { | 18 | 22 | "id": "flag-optional-value-optional", | 19 | 23 | "doc": "A value declared `[n]` is square-bracketed, independently of the flag's own brackets.", | 20 | 24 | "spec": "name \"ex\"\nbin \"ex\"\nflag \"--opt [n]\" help=\"A number, or not\"\n", | 21 | | - "expect": { "usage": "ex [--opt [n]]" } | | 25 | + "expect": { | | 26 | + "usage": "ex [--opt [n]]" | | 27 | + } | 22 | 28 | }, | 23 | 29 | { | 24 | 30 | "id": "flag-required-value-defaulted", | 25 | 31 | "doc": "A default on the flag's `arg` node relaxes the value's brackets and leaves the flag's alone.", | 26 | 32 | "spec": "name \"ex\"\nbin \"ex\"\nflag \"--jobs <n>\" required=#true help=\"How many\" {\n arg \"<n>\" default=\"4\"\n}\n", | 27 | | - "expect": { "usage": "ex <--jobs [n]>" } | | 33 | + "expect": { | | 34 | + "usage": "ex <--jobs [n]>" | | 35 | + } | 28 | 36 | }, | 29 | 37 | { | 30 | 38 | "id": "flag-default-on-the-flag", | 31 | 39 | "doc": "The same default written on the flag instead relaxes the other pair: the flag becomes optional and the value stays angled.", | 32 | 40 | "spec": "name \"ex\"\nbin \"ex\"\nflag \"--jobs <n>\" default=\"4\" help=\"How many\"\n", | 33 | | - "expect": { "usage": "ex [--jobs <n>]" } | | 41 | + "expect": { | | 42 | + "usage": "ex [--jobs <n>]" | | 43 | + } | 34 | 44 | }, | 35 | 45 | { | 36 | 46 | "id": "flag-value-variadic-optional", | 37 | 47 | "doc": "The ellipsis belongs to the value and sits outside its brackets, whichever pair they are.", | 38 | 48 | "spec": "name \"ex\"\nbin \"ex\"\nflag \"--inc [pattern]...\" help=\"Patterns to include\"\n", | 39 | | - "expect": { "usage": "ex [--inc [pattern]…]" } | | 49 | + "expect": { | | 50 | + "usage": "ex [--inc [pattern]…]" | | 51 | + } | 40 | 52 | }, | 41 | 53 | { | 42 | 54 | "id": "flag-value-variadic-required", | 43 | 55 | "doc": "A required variadic value, with the flag required too.", | 44 | 56 | "spec": "name \"ex\"\nbin \"ex\"\nflag \"--inc <pattern>...\" required=#true help=\"Patterns to include\"\n", | 45 | | - "expect": { "usage": "ex <--inc <pattern>…>" } | | 57 | + "expect": { | | 58 | + "usage": "ex <--inc <pattern>…>" | | 59 | + } | 46 | 60 | }, | 47 | 61 | { | 48 | 62 | "id": "flag-repeatable-with-optional-value", | 49 | 63 | "doc": "A repeatable flag's own ellipsis follows the spellings, before the value — so a repeatable flag taking an optional value shows both.", | 50 | 64 | "spec": "name \"ex\"\nbin \"ex\"\nflag \"--jobs [n]\" var=#true required=#true help=\"How many\"\n", | 51 | | - "expect": { "usage": "ex <--jobs… [n]>" } | | 65 | + "expect": { | | 66 | + "usage": "ex <--jobs… [n]>" | | 67 | + } | 52 | 68 | }, | 53 | 69 | { | 54 | 70 | "id": "flag-value-named-differently", | 55 | 71 | "doc": "The value's placeholder is the `arg` node's name, not the flag's; a flag whose spellings do not imply its declared name says the name first.", | 56 | 72 | "spec": "name \"ex\"\nbin \"ex\"\nflag \"jobs: -j [n]\" help=\"How many\"\n", | 57 | | - "expect": { "usage": "ex [jobs: -j [n]]" } | | 73 | + "expect": { | | 74 | + "usage": "ex [jobs: -j [n]]" | | 75 | + } | 58 | 76 | }, | 59 | 77 | { | 60 | 78 | "id": "flag-value-optional-on-the-page", | |
Collapse file Copy file name to clipboardExpand all lines: corpus/render/03-sections.json +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 337 | 337 | ] | 338 | 338 | }, | 339 | 339 | "reference": { | 340 | | - "diverges": "usage-lib's help renderer ignores a declared `usage` and writes the generated line; its manpage renderer honours it (`lib/src/docs/manpage/renderer.rs`). usage-argv honours it on the root page, which is what #965 added it for. Recorded rather than fixed here because it is the reference that needs changing, not the expectation." | | 340 | + "diverges": "usage-lib's help renderer ignores a declared `usage` and writes the generated line; its manpage renderer honours it (`lib/src/docs/manpage/renderer.rs`). usage-argv honours it on the root page, which is what #965 added it for. The fleet gate cannot see this even though six of its seven CLIs declare one, because `xtask gen-shadow` does not carry the node into the shadow it generates — so each shadow's `Spec::usage` is `None` and both sides render the generated line. Recorded rather than fixed here because it is the reference that needs changing, not the expectation." | 341 | 341 | } | 342 | 342 | } | 343 | 343 | ] | |
Collapse file Copy file name to clipboardExpand all lines: corpus/render/README.md +35-20Lines changed: 35 additions & 20 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -11,28 +11,43 @@ these without reimplementing a test format. If you are rendering help from a usa | 11 | 11 | Go, in JavaScript, or as a second Rust implementation — this directory is the definition of | 12 | 12 | correct. | 13 | 13 |
| 14 | | -## Why this exists beside the mise fixture | | 14 | +## Why this exists beside the fleet gate | 15 | 15 |
| 16 | 16 | `benches/gate/tests/help.rs` renders all 211 of mise's commands with `usage-argv` and compares | 17 | | -each page against usage-lib byte for byte. That is the check that decides whether an adopter's | 18 | | -help output changes, and no hand-written corpus will ever match it for scale. | 19 | | - | 20 | | -What it cannot do is cover a shape mise does not use. A flag whose _value_ is optional is one: | 21 | | -every flag value mise declares is required and undefaulted, so the fixture runs entirely | 22 | | -through the one combination where the two implementations happen to agree. `[--opt [n]]` | 23 | | -rendered as `[--opt <n>]` for as long as `usage-argv` existed, and the 211-command comparison | 24 | | -passed the whole time. | 25 | | - | 26 | | -So the two are complements, and the split is worth stating plainly: | 27 | | - | 28 | | -| | asks | covers | | 29 | | -| ---------------- | ---------------------------------------------------- | ---------------------------------- | | 30 | | -| the mise fixture | does a real CLI still render the same? | one CLI, exhaustively | | 31 | | -| this corpus | does every shape a spec can declare render the same? | every shape, one command at a time | | 32 | | - | 33 | | -A rule that only one of them can catch belongs in whichever one catches it. In practice that | 34 | | -means: if you fix a rendering bug, the regression test goes _here_ unless mise already | 35 | | -exercises the shape. | | 17 | +each page against usage-lib byte for byte; `fleet.rs` beside it does the same for the other six | | 18 | +jdx CLIs. Together they are the check that decides whether an adopter's help output changes, and | | 19 | +no hand-written corpus will match them for scale. | | 20 | + | | 21 | +What they cannot do is cover a shape no CLI in the fleet uses. The fleet was one CLI until #972, | | 22 | +and widening it found three bugs in a week — the version banner, an optional flag value, a | | 23 | +description ending in a break. That is the argument for this corpus rather than against it: | | 24 | +seven real CLIs still leave gaps, and the gaps are not exotic. | | 25 | + | | 26 | +Flag values are the worked example. There are four pairings of "must the flag be given" against | | 27 | +"must its value be given", and across all 809 value-taking flags in mise and the fleet: | | 28 | + | | 29 | +| pairing | in the fleet | | | 30 | +| -------------------------------------------------------- | ---------------------------- | | | 31 | +| `[--tool <TOOL>]` optional flag, required value | 796 | | | 32 | +| `<--v <n>>` both required | 8 | | | 33 | +| `[--opt [n]]` both optional | 5, all in pitchfork and aube | | | 34 | +| `<--jobs [n]>` required flag, optional value | **0** | | | 35 | +| a value carrying a `default`, which relaxes its brackets | **0** | | | 36 | + | | 37 | +The third row is what #969 fixed, and pitchfork is the only reason it was visible. The last two | | 38 | +rows are shapes a spec can declare that nothing in the fleet does — so nothing but a written-down | | 39 | +case will hold them. | | 40 | + | | 41 | +So the two are complements: | | 42 | + | | 43 | +| | asks | covers | | | 44 | +| -------------- | ---------------------------------------------------- | ---------------------------------- | | | 45 | +| the fleet gate | do seven real CLIs still render the same? | those CLIs, exhaustively | | | 46 | +| this corpus | does every shape a spec can declare render the same? | every shape, one command at a time | | | 47 | + | | 48 | +A rule that only one of them can catch belongs in whichever one catches it. In practice: if you | | 49 | +fix a rendering bug, the regression test goes _here_ unless a fleet CLI already exercises the | | 50 | +shape — and if one does, add it there instead, where it is checked at scale. | 36 | 51 |
| 37 | 52 | ## Format | 38 | 53 |
| |
|