@optique/core 0.7.11 → 0.7.12

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.
@@ -193,7 +193,9 @@ function or(...args) {
193
193
  });
194
194
  },
195
195
  getDocFragments(state, _defaultValue) {
196
+ let brief;
196
197
  let description;
198
+ let footer;
197
199
  let fragments;
198
200
  if (state.kind === "unavailable" || state.state == null) fragments = parsers.flatMap((p) => p.getDocFragments({ kind: "unavailable" }, void 0).fragments);
199
201
  else {
@@ -203,7 +205,9 @@ function or(...args) {
203
205
  state: parserResult.next.state
204
206
  } : { kind: "unavailable" };
205
207
  const docFragments = parsers[index].getDocFragments(innerState, void 0);
208
+ brief = docFragments.brief;
206
209
  description = docFragments.description;
210
+ footer = docFragments.footer;
207
211
  fragments = docFragments.fragments;
208
212
  }
209
213
  const entries = fragments.filter((f) => f.type === "entry");
@@ -214,7 +218,9 @@ function or(...args) {
214
218
  else sections.push(fragment);
215
219
  }
216
220
  return {
221
+ brief,
217
222
  description,
223
+ footer,
218
224
  fragments: [...sections.map((s) => ({
219
225
  ...s,
220
226
  type: "section"
@@ -337,6 +343,7 @@ function longestMatch(...args) {
337
343
  });
338
344
  },
339
345
  getDocFragments(state, _defaultValue) {
346
+ let brief;
340
347
  let description;
341
348
  let footer;
342
349
  let fragments;
@@ -348,12 +355,14 @@ function longestMatch(...args) {
348
355
  kind: "available",
349
356
  state: result.next.state
350
357
  });
358
+ brief = docResult.brief;
351
359
  description = docResult.description;
352
360
  footer = docResult.footer;
353
361
  fragments = docResult.fragments;
354
362
  } else fragments = parsers.flatMap((p) => p.getDocFragments({ kind: "unavailable" }).fragments);
355
363
  }
356
364
  return {
365
+ brief,
357
366
  description,
358
367
  fragments,
359
368
  footer
@@ -193,7 +193,9 @@ function or(...args) {
193
193
  });
194
194
  },
195
195
  getDocFragments(state, _defaultValue) {
196
+ let brief;
196
197
  let description;
198
+ let footer;
197
199
  let fragments;
198
200
  if (state.kind === "unavailable" || state.state == null) fragments = parsers.flatMap((p) => p.getDocFragments({ kind: "unavailable" }, void 0).fragments);
199
201
  else {
@@ -203,7 +205,9 @@ function or(...args) {
203
205
  state: parserResult.next.state
204
206
  } : { kind: "unavailable" };
205
207
  const docFragments = parsers[index].getDocFragments(innerState, void 0);
208
+ brief = docFragments.brief;
206
209
  description = docFragments.description;
210
+ footer = docFragments.footer;
207
211
  fragments = docFragments.fragments;
208
212
  }
209
213
  const entries = fragments.filter((f) => f.type === "entry");
@@ -214,7 +218,9 @@ function or(...args) {
214
218
  else sections.push(fragment);
215
219
  }
216
220
  return {
221
+ brief,
217
222
  description,
223
+ footer,
218
224
  fragments: [...sections.map((s) => ({
219
225
  ...s,
220
226
  type: "section"
@@ -337,6 +343,7 @@ function longestMatch(...args) {
337
343
  });
338
344
  },
339
345
  getDocFragments(state, _defaultValue) {
346
+ let brief;
340
347
  let description;
341
348
  let footer;
342
349
  let fragments;
@@ -348,12 +355,14 @@ function longestMatch(...args) {
348
355
  kind: "available",
349
356
  state: result.next.state
350
357
  });
358
+ brief = docResult.brief;
351
359
  description = docResult.description;
352
360
  footer = docResult.footer;
353
361
  fragments = docResult.fragments;
354
362
  } else fragments = parsers.flatMap((p) => p.getDocFragments({ kind: "unavailable" }).fragments);
355
363
  }
356
364
  return {
365
+ brief,
357
366
  description,
358
367
  fragments,
359
368
  footer
package/dist/doc.d.cts CHANGED
@@ -60,6 +60,12 @@ type DocFragment = {
60
60
  * a final document page.
61
61
  */
62
62
  interface DocFragments {
63
+ /**
64
+ * An optional brief that provides a short summary for the collection
65
+ * of fragments.
66
+ * @since 0.7.12
67
+ */
68
+ readonly brief?: Message;
63
69
  /**
64
70
  * An optional description that applies to the entire collection of fragments.
65
71
  */
package/dist/doc.d.ts CHANGED
@@ -60,6 +60,12 @@ type DocFragment = {
60
60
  * a final document page.
61
61
  */
62
62
  interface DocFragments {
63
+ /**
64
+ * An optional brief that provides a short summary for the collection
65
+ * of fragments.
66
+ * @since 0.7.12
67
+ */
68
+ readonly brief?: Message;
63
69
  /**
64
70
  * An optional description that applies to the entire collection of fragments.
65
71
  */
package/dist/facade.cjs CHANGED
@@ -561,11 +561,13 @@ function run(parser, programName, args, options = {}) {
561
561
  const doc = require_parser.getDocPage(helpGeneratorParser, classified.commands);
562
562
  if (doc != null) {
563
563
  const isMetaCommandHelp = (completionName === "singular" || completionName === "both" ? requestedCommand === "completion" : false) || (completionName === "plural" || completionName === "both" ? requestedCommand === "completions" : false) || requestedCommand === "help" || requestedCommand === "version";
564
+ const isSubcommandHelp = classified.commands.length > 0;
565
+ const shouldOverride = !isMetaCommandHelp && !isSubcommandHelp;
564
566
  const augmentedDoc = {
565
567
  ...doc,
566
- brief: !isMetaCommandHelp ? brief ?? doc.brief : doc.brief,
567
- description: !isMetaCommandHelp ? description ?? doc.description : doc.description,
568
- footer: !isMetaCommandHelp ? footer ?? doc.footer : doc.footer
568
+ brief: shouldOverride ? brief ?? doc.brief : doc.brief ?? brief,
569
+ description: shouldOverride ? description ?? doc.description : doc.description ?? description,
570
+ footer: shouldOverride ? footer ?? doc.footer : doc.footer ?? footer
569
571
  };
570
572
  stdout(require_doc.formatDocPage(programName, augmentedDoc, {
571
573
  colors,
package/dist/facade.js CHANGED
@@ -561,11 +561,13 @@ function run(parser, programName, args, options = {}) {
561
561
  const doc = getDocPage(helpGeneratorParser, classified.commands);
562
562
  if (doc != null) {
563
563
  const isMetaCommandHelp = (completionName === "singular" || completionName === "both" ? requestedCommand === "completion" : false) || (completionName === "plural" || completionName === "both" ? requestedCommand === "completions" : false) || requestedCommand === "help" || requestedCommand === "version";
564
+ const isSubcommandHelp = classified.commands.length > 0;
565
+ const shouldOverride = !isMetaCommandHelp && !isSubcommandHelp;
564
566
  const augmentedDoc = {
565
567
  ...doc,
566
- brief: !isMetaCommandHelp ? brief ?? doc.brief : doc.brief,
567
- description: !isMetaCommandHelp ? description ?? doc.description : doc.description,
568
- footer: !isMetaCommandHelp ? footer ?? doc.footer : doc.footer
568
+ brief: shouldOverride ? brief ?? doc.brief : doc.brief ?? brief,
569
+ description: shouldOverride ? description ?? doc.description : doc.description ?? description,
570
+ footer: shouldOverride ? footer ?? doc.footer : doc.footer ?? footer
569
571
  };
570
572
  stdout(formatDocPage(programName, augmentedDoc, {
571
573
  colors,
package/dist/parser.cjs CHANGED
@@ -159,7 +159,7 @@ function getDocPage(parser, args = []) {
159
159
  if (!result.success) break;
160
160
  context = result.next;
161
161
  } while (context.buffer.length > 0);
162
- const { description, fragments, footer } = parser.getDocFragments({
162
+ const { brief, description, fragments, footer } = parser.getDocFragments({
163
163
  kind: "available",
164
164
  state: context.state
165
165
  }, void 0);
@@ -184,6 +184,7 @@ function getDocPage(parser, args = []) {
184
184
  return {
185
185
  usage,
186
186
  sections,
187
+ ...brief != null && { brief },
187
188
  ...description != null && { description },
188
189
  ...footer != null && { footer }
189
190
  };
package/dist/parser.js CHANGED
@@ -159,7 +159,7 @@ function getDocPage(parser, args = []) {
159
159
  if (!result.success) break;
160
160
  context = result.next;
161
161
  } while (context.buffer.length > 0);
162
- const { description, fragments, footer } = parser.getDocFragments({
162
+ const { brief, description, fragments, footer } = parser.getDocFragments({
163
163
  kind: "available",
164
164
  state: context.state
165
165
  }, void 0);
@@ -184,6 +184,7 @@ function getDocPage(parser, args = []) {
184
184
  return {
185
185
  usage,
186
186
  sections,
187
+ ...brief != null && { brief },
187
188
  ...description != null && { description },
188
189
  ...footer != null && { footer }
189
190
  };
@@ -725,6 +725,7 @@ function command(name, parser, options = {}) {
725
725
  const innerFragments = parser.getDocFragments(innerState, defaultValue);
726
726
  return {
727
727
  ...innerFragments,
728
+ brief: innerFragments.brief ?? options.brief,
728
729
  description: innerFragments.description ?? options.description,
729
730
  footer: innerFragments.footer ?? options.footer
730
731
  };
@@ -725,6 +725,7 @@ function command(name, parser, options = {}) {
725
725
  const innerFragments = parser.getDocFragments(innerState, defaultValue);
726
726
  return {
727
727
  ...innerFragments,
728
+ brief: innerFragments.brief ?? options.brief,
728
729
  description: innerFragments.description ?? options.description,
729
730
  footer: innerFragments.footer ?? options.footer
730
731
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "0.7.11",
3
+ "version": "0.7.12",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",