@optique/core 1.3.0-dev.2532 → 1.3.0-dev.2536

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/doc.cjs CHANGED
@@ -193,7 +193,8 @@ function defaultSectionOrder(a, b) {
193
193
  * control characters, or if `maxWidth` is not a finite integer.
194
194
  * @throws {RangeError} If any entry needs a description column and `maxWidth`
195
195
  * is too small to fit the minimum layout (less than `termIndent + 4`), or if
196
- * `showChoices.maxItems` is less than `1`.
196
+ * `showChoices.maxItems` is less than `1`, or if a theme color is invalid
197
+ * (even when colors are disabled).
197
198
  *
198
199
  * @example
199
200
  * ```typescript
package/dist/doc.d.cts CHANGED
@@ -339,7 +339,8 @@ interface DocPageFormatOptions {
339
339
  * control characters, or if `maxWidth` is not a finite integer.
340
340
  * @throws {RangeError} If any entry needs a description column and `maxWidth`
341
341
  * is too small to fit the minimum layout (less than `termIndent + 4`), or if
342
- * `showChoices.maxItems` is less than `1`.
342
+ * `showChoices.maxItems` is less than `1`, or if a theme color is invalid
343
+ * (even when colors are disabled).
343
344
  *
344
345
  * @example
345
346
  * ```typescript
package/dist/doc.d.ts CHANGED
@@ -339,7 +339,8 @@ interface DocPageFormatOptions {
339
339
  * control characters, or if `maxWidth` is not a finite integer.
340
340
  * @throws {RangeError} If any entry needs a description column and `maxWidth`
341
341
  * is too small to fit the minimum layout (less than `termIndent + 4`), or if
342
- * `showChoices.maxItems` is less than `1`.
342
+ * `showChoices.maxItems` is less than `1`, or if a theme color is invalid
343
+ * (even when colors are disabled).
343
344
  *
344
345
  * @example
345
346
  * ```typescript
package/dist/doc.js CHANGED
@@ -193,7 +193,8 @@ function defaultSectionOrder(a, b) {
193
193
  * control characters, or if `maxWidth` is not a finite integer.
194
194
  * @throws {RangeError} If any entry needs a description column and `maxWidth`
195
195
  * is too small to fit the minimum layout (less than `termIndent + 4`), or if
196
- * `showChoices.maxItems` is less than `1`.
196
+ * `showChoices.maxItems` is less than `1`, or if a theme color is invalid
197
+ * (even when colors are disabled).
197
198
  *
198
199
  * @example
199
200
  * ```typescript
package/dist/facade.cjs CHANGED
@@ -531,9 +531,12 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
531
531
  const callOnCompletion = (code) => onCompletion(code);
532
532
  if (!shellName) {
533
533
  const error = require_message.message`Missing shell name for completion.`;
534
- stderr(`${errorLabel()}${formatMessage(error, {
534
+ const prefix = errorLabel();
535
+ stderr(`${prefix}${formatMessage(error, {
535
536
  colors,
536
- quotes: !colors
537
+ quotes: !colors,
538
+ maxWidth,
539
+ initialWidth: require_displaywidth.getDisplayWidth(prefix.split("\n").at(-1) ?? "")
537
540
  })}\n`);
538
541
  if (completionParser) {
539
542
  const displayName = isOptionMode ? completionOptionDisplayName ?? "--completion" : completionCommandDisplayName ?? "completion";
@@ -562,9 +565,12 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
562
565
  available.push(require_message.value(name));
563
566
  }
564
567
  const error = require_message.message`Unsupported shell ${shellName}. Available shells: ${available}.`;
565
- stderr(`${errorLabel()}${formatMessage(error, {
568
+ const prefix = errorLabel();
569
+ stderr(`${prefix}${formatMessage(error, {
566
570
  colors,
567
- quotes: !colors
571
+ quotes: !colors,
572
+ maxWidth,
573
+ initialWidth: require_displaywidth.getDisplayWidth(prefix.split("\n").at(-1) ?? "")
568
574
  })}`);
569
575
  return require_mode_dispatch.dispatchByMode(parser.mode, () => {
570
576
  const result = callOnError(1, error);
@@ -1051,11 +1057,14 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
1051
1057
  maxWidth: maxWidth == null ? void 0 : maxWidth - usageLabelWidth(),
1052
1058
  expandCommands: true
1053
1059
  }), usageLabelWidth())}`);
1060
+ const prefix = errorLabel();
1054
1061
  const errorMessage = formatMessage(validationError, {
1062
+ initialWidth: require_displaywidth.getDisplayWidth(prefix.split("\n").at(-1) ?? ""),
1063
+ maxWidth,
1055
1064
  colors,
1056
1065
  quotes: !colors
1057
1066
  });
1058
- stderr(`${errorLabel()}${errorMessage}`);
1067
+ stderr(`${prefix}${errorMessage}`);
1059
1068
  return onError(1, validationError);
1060
1069
  };
1061
1070
  const displayHelp = (doc) => {
@@ -1168,11 +1177,14 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
1168
1177
  maxWidth: maxWidth == null ? void 0 : maxWidth - usageLabelWidth(),
1169
1178
  expandCommands: true
1170
1179
  }), usageLabelWidth())}`);
1180
+ const prefix = errorLabel();
1171
1181
  const errorMessage = formatMessage(classified.error, {
1182
+ initialWidth: require_displaywidth.getDisplayWidth(prefix.split("\n").at(-1) ?? ""),
1183
+ maxWidth,
1172
1184
  colors,
1173
1185
  quotes: !colors
1174
1186
  });
1175
- stderr(`${errorLabel()}${errorMessage}`);
1187
+ stderr(`${prefix}${errorMessage}`);
1176
1188
  return onError(1, classified.error);
1177
1189
  };
1178
1190
  if (aboveError === "help") {
package/dist/facade.js CHANGED
@@ -531,9 +531,12 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
531
531
  const callOnCompletion = (code) => onCompletion(code);
532
532
  if (!shellName) {
533
533
  const error = message`Missing shell name for completion.`;
534
- stderr(`${errorLabel()}${formatMessage(error, {
534
+ const prefix = errorLabel();
535
+ stderr(`${prefix}${formatMessage(error, {
535
536
  colors,
536
- quotes: !colors
537
+ quotes: !colors,
538
+ maxWidth,
539
+ initialWidth: getDisplayWidth(prefix.split("\n").at(-1) ?? "")
537
540
  })}\n`);
538
541
  if (completionParser) {
539
542
  const displayName = isOptionMode ? completionOptionDisplayName ?? "--completion" : completionCommandDisplayName ?? "completion";
@@ -562,9 +565,12 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
562
565
  available.push(value(name));
563
566
  }
564
567
  const error = message`Unsupported shell ${shellName}. Available shells: ${available}.`;
565
- stderr(`${errorLabel()}${formatMessage(error, {
568
+ const prefix = errorLabel();
569
+ stderr(`${prefix}${formatMessage(error, {
566
570
  colors,
567
- quotes: !colors
571
+ quotes: !colors,
572
+ maxWidth,
573
+ initialWidth: getDisplayWidth(prefix.split("\n").at(-1) ?? "")
568
574
  })}`);
569
575
  return dispatchByMode(parser.mode, () => {
570
576
  const result = callOnError(1, error);
@@ -1051,11 +1057,14 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
1051
1057
  maxWidth: maxWidth == null ? void 0 : maxWidth - usageLabelWidth(),
1052
1058
  expandCommands: true
1053
1059
  }), usageLabelWidth())}`);
1060
+ const prefix = errorLabel();
1054
1061
  const errorMessage = formatMessage(validationError, {
1062
+ initialWidth: getDisplayWidth(prefix.split("\n").at(-1) ?? ""),
1063
+ maxWidth,
1055
1064
  colors,
1056
1065
  quotes: !colors
1057
1066
  });
1058
- stderr(`${errorLabel()}${errorMessage}`);
1067
+ stderr(`${prefix}${errorMessage}`);
1059
1068
  return onError(1, validationError);
1060
1069
  };
1061
1070
  const displayHelp = (doc) => {
@@ -1168,11 +1177,14 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
1168
1177
  maxWidth: maxWidth == null ? void 0 : maxWidth - usageLabelWidth(),
1169
1178
  expandCommands: true
1170
1179
  }), usageLabelWidth())}`);
1180
+ const prefix = errorLabel();
1171
1181
  const errorMessage = formatMessage(classified.error, {
1182
+ initialWidth: getDisplayWidth(prefix.split("\n").at(-1) ?? ""),
1183
+ maxWidth,
1172
1184
  colors,
1173
1185
  quotes: !colors
1174
1186
  });
1175
- stderr(`${errorLabel()}${errorMessage}`);
1187
+ stderr(`${prefix}${errorMessage}`);
1176
1188
  return onError(1, classified.error);
1177
1189
  };
1178
1190
  if (aboveError === "help") {
package/dist/usage.cjs CHANGED
@@ -181,6 +181,8 @@ function extractArgumentMetavars(usage) {
181
181
  * @returns A formatted string representation of the usage description.
182
182
  * @throws {TypeError} If `programName` is not a string, is empty,
183
183
  * whitespace-only, or contains control characters.
184
+ * @throws {RangeError} If a theme supplies an invalid RGB channel or palette
185
+ * index, even when colors are disabled.
184
186
  */
185
187
  function formatUsage(programName, usage, options = {}) {
186
188
  options = {
package/dist/usage.d.cts CHANGED
@@ -393,6 +393,8 @@ interface UsageFormatOptions {
393
393
  * @returns A formatted string representation of the usage description.
394
394
  * @throws {TypeError} If `programName` is not a string, is empty,
395
395
  * whitespace-only, or contains control characters.
396
+ * @throws {RangeError} If a theme supplies an invalid RGB channel or palette
397
+ * index, even when colors are disabled.
396
398
  */
397
399
  declare function formatUsage(programName: string, usage: Usage, options?: UsageFormatOptions): string;
398
400
  /**
package/dist/usage.d.ts CHANGED
@@ -393,6 +393,8 @@ interface UsageFormatOptions {
393
393
  * @returns A formatted string representation of the usage description.
394
394
  * @throws {TypeError} If `programName` is not a string, is empty,
395
395
  * whitespace-only, or contains control characters.
396
+ * @throws {RangeError} If a theme supplies an invalid RGB channel or palette
397
+ * index, even when colors are disabled.
396
398
  */
397
399
  declare function formatUsage(programName: string, usage: Usage, options?: UsageFormatOptions): string;
398
400
  /**
package/dist/usage.js CHANGED
@@ -181,6 +181,8 @@ function extractArgumentMetavars(usage) {
181
181
  * @returns A formatted string representation of the usage description.
182
182
  * @throws {TypeError} If `programName` is not a string, is empty,
183
183
  * whitespace-only, or contains control characters.
184
+ * @throws {RangeError} If a theme supplies an invalid RGB channel or palette
185
+ * index, even when colors are disabled.
184
186
  */
185
187
  function formatUsage(programName, usage, options = {}) {
186
188
  options = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.3.0-dev.2532",
3
+ "version": "1.3.0-dev.2536",
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.0-dev.2532+2ec45dbf",
240
+ "@optique/env": "1.3.0-dev.2536+22f9c880",
241
241
  "@types/node": "^24.0.0",
242
242
  "fast-check": "^4.7.0",
243
243
  "tsdown": "^0.13.0",