@optique/core 1.0.0-dev.478 → 1.0.0-dev.483

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/facade.cjs CHANGED
@@ -615,6 +615,35 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
615
615
  stderr(`Error: ${errorMessage}`);
616
616
  return onError(1);
617
617
  };
618
+ const displayHelp = (doc) => {
619
+ if (doc != null) {
620
+ const isMetaCommandHelp = requestedCommand != null && completionCommandNames.includes(requestedCommand) || requestedCommand != null && helpCommandNames.includes(requestedCommand) || requestedCommand != null && versionCommandNames.includes(requestedCommand);
621
+ const isSubcommandHelp = classified.commands.length > 0;
622
+ const isTopLevel = !isSubcommandHelp;
623
+ const shouldOverride = !isMetaCommandHelp && !isSubcommandHelp;
624
+ const augmentedDoc = {
625
+ ...doc,
626
+ brief: shouldOverride ? brief ?? doc.brief : doc.brief,
627
+ description: shouldOverride ? description ?? doc.description : doc.description,
628
+ examples: isTopLevel && !isMetaCommandHelp ? examples ?? doc.examples : void 0,
629
+ author: isTopLevel && !isMetaCommandHelp ? author ?? doc.author : void 0,
630
+ bugs: isTopLevel && !isMetaCommandHelp ? bugs ?? doc.bugs : void 0,
631
+ footer: shouldOverride ? footer ?? doc.footer : doc.footer ?? footer
632
+ };
633
+ stdout(require_doc.formatDocPage(programName, augmentedDoc, {
634
+ colors,
635
+ maxWidth,
636
+ showDefault,
637
+ showChoices,
638
+ sectionOrder
639
+ }));
640
+ }
641
+ try {
642
+ return onHelp(0);
643
+ } catch {
644
+ return onHelp();
645
+ }
646
+ };
618
647
  if (classified.commands.length > 0) {
619
648
  let validationContext = {
620
649
  buffer: [...classified.commands],
@@ -655,35 +684,6 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
655
684
  }
656
685
  if (validationResult != null) return reportInvalidHelpCommand(validationResult);
657
686
  }
658
- const displayHelp = (doc) => {
659
- if (doc != null) {
660
- const isMetaCommandHelp = requestedCommand != null && completionCommandNames.includes(requestedCommand) || requestedCommand != null && helpCommandNames.includes(requestedCommand) || requestedCommand != null && versionCommandNames.includes(requestedCommand);
661
- const isSubcommandHelp = classified.commands.length > 0;
662
- const isTopLevel = !isSubcommandHelp;
663
- const shouldOverride = !isMetaCommandHelp && !isSubcommandHelp;
664
- const augmentedDoc = {
665
- ...doc,
666
- brief: shouldOverride ? brief ?? doc.brief : doc.brief,
667
- description: shouldOverride ? description ?? doc.description : doc.description,
668
- examples: isTopLevel && !isMetaCommandHelp ? examples ?? doc.examples : void 0,
669
- author: isTopLevel && !isMetaCommandHelp ? author ?? doc.author : void 0,
670
- bugs: isTopLevel && !isMetaCommandHelp ? bugs ?? doc.bugs : void 0,
671
- footer: shouldOverride ? footer ?? doc.footer : doc.footer ?? footer
672
- };
673
- stdout(require_doc.formatDocPage(programName, augmentedDoc, {
674
- colors,
675
- maxWidth,
676
- showDefault,
677
- showChoices,
678
- sectionOrder
679
- }));
680
- }
681
- try {
682
- return onHelp(0);
683
- } catch {
684
- return onHelp();
685
- }
686
- };
687
687
  const docOrPromise = require_parser.getDocPage(helpGeneratorParser, classified.commands);
688
688
  if (docOrPromise instanceof Promise) return docOrPromise.then(displayHelp);
689
689
  return displayHelp(docOrPromise);
package/dist/facade.js CHANGED
@@ -615,6 +615,35 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
615
615
  stderr(`Error: ${errorMessage}`);
616
616
  return onError(1);
617
617
  };
618
+ const displayHelp = (doc) => {
619
+ if (doc != null) {
620
+ const isMetaCommandHelp = requestedCommand != null && completionCommandNames.includes(requestedCommand) || requestedCommand != null && helpCommandNames.includes(requestedCommand) || requestedCommand != null && versionCommandNames.includes(requestedCommand);
621
+ const isSubcommandHelp = classified.commands.length > 0;
622
+ const isTopLevel = !isSubcommandHelp;
623
+ const shouldOverride = !isMetaCommandHelp && !isSubcommandHelp;
624
+ const augmentedDoc = {
625
+ ...doc,
626
+ brief: shouldOverride ? brief ?? doc.brief : doc.brief,
627
+ description: shouldOverride ? description ?? doc.description : doc.description,
628
+ examples: isTopLevel && !isMetaCommandHelp ? examples ?? doc.examples : void 0,
629
+ author: isTopLevel && !isMetaCommandHelp ? author ?? doc.author : void 0,
630
+ bugs: isTopLevel && !isMetaCommandHelp ? bugs ?? doc.bugs : void 0,
631
+ footer: shouldOverride ? footer ?? doc.footer : doc.footer ?? footer
632
+ };
633
+ stdout(formatDocPage(programName, augmentedDoc, {
634
+ colors,
635
+ maxWidth,
636
+ showDefault,
637
+ showChoices,
638
+ sectionOrder
639
+ }));
640
+ }
641
+ try {
642
+ return onHelp(0);
643
+ } catch {
644
+ return onHelp();
645
+ }
646
+ };
618
647
  if (classified.commands.length > 0) {
619
648
  let validationContext = {
620
649
  buffer: [...classified.commands],
@@ -655,35 +684,6 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
655
684
  }
656
685
  if (validationResult != null) return reportInvalidHelpCommand(validationResult);
657
686
  }
658
- const displayHelp = (doc) => {
659
- if (doc != null) {
660
- const isMetaCommandHelp = requestedCommand != null && completionCommandNames.includes(requestedCommand) || requestedCommand != null && helpCommandNames.includes(requestedCommand) || requestedCommand != null && versionCommandNames.includes(requestedCommand);
661
- const isSubcommandHelp = classified.commands.length > 0;
662
- const isTopLevel = !isSubcommandHelp;
663
- const shouldOverride = !isMetaCommandHelp && !isSubcommandHelp;
664
- const augmentedDoc = {
665
- ...doc,
666
- brief: shouldOverride ? brief ?? doc.brief : doc.brief,
667
- description: shouldOverride ? description ?? doc.description : doc.description,
668
- examples: isTopLevel && !isMetaCommandHelp ? examples ?? doc.examples : void 0,
669
- author: isTopLevel && !isMetaCommandHelp ? author ?? doc.author : void 0,
670
- bugs: isTopLevel && !isMetaCommandHelp ? bugs ?? doc.bugs : void 0,
671
- footer: shouldOverride ? footer ?? doc.footer : doc.footer ?? footer
672
- };
673
- stdout(formatDocPage(programName, augmentedDoc, {
674
- colors,
675
- maxWidth,
676
- showDefault,
677
- showChoices,
678
- sectionOrder
679
- }));
680
- }
681
- try {
682
- return onHelp(0);
683
- } catch {
684
- return onHelp();
685
- }
686
- };
687
687
  const docOrPromise = getDocPage(helpGeneratorParser, classified.commands);
688
688
  if (docOrPromise instanceof Promise) return docOrPromise.then(displayHelp);
689
689
  return displayHelp(docOrPromise);
@@ -163,7 +163,8 @@ function* suggestOptionSync(optionNames$1, valueParser, hidden, context, prefix)
163
163
  }
164
164
  }
165
165
  } else {
166
- if (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/")) {
166
+ const expectingValue = context.buffer.length > 0 && optionNames$1.includes(context.buffer[context.buffer.length - 1]);
167
+ if (!expectingValue && (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/"))) {
167
168
  for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
168
169
  if (prefix === "-" && optionName$1.length !== 2) continue;
169
170
  yield {
@@ -244,7 +245,8 @@ async function* suggestOptionAsync(optionNames$1, valueParser, hidden, context,
244
245
  }
245
246
  }
246
247
  } else {
247
- if (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/")) {
248
+ const expectingValue = context.buffer.length > 0 && optionNames$1.includes(context.buffer[context.buffer.length - 1]);
249
+ if (!expectingValue && (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/"))) {
248
250
  for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
249
251
  if (prefix === "-" && optionName$1.length !== 2) continue;
250
252
  yield {
@@ -163,7 +163,8 @@ function* suggestOptionSync(optionNames$1, valueParser, hidden, context, prefix)
163
163
  }
164
164
  }
165
165
  } else {
166
- if (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/")) {
166
+ const expectingValue = context.buffer.length > 0 && optionNames$1.includes(context.buffer[context.buffer.length - 1]);
167
+ if (!expectingValue && (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/"))) {
167
168
  for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
168
169
  if (prefix === "-" && optionName$1.length !== 2) continue;
169
170
  yield {
@@ -244,7 +245,8 @@ async function* suggestOptionAsync(optionNames$1, valueParser, hidden, context,
244
245
  }
245
246
  }
246
247
  } else {
247
- if (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/")) {
248
+ const expectingValue = context.buffer.length > 0 && optionNames$1.includes(context.buffer[context.buffer.length - 1]);
249
+ if (!expectingValue && (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/"))) {
248
250
  for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
249
251
  if (prefix === "-" && optionName$1.length !== 2) continue;
250
252
  yield {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.478+277748a4",
3
+ "version": "1.0.0-dev.483+8c78671b",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",