@optique/core 1.3.0-dev.2530 → 1.3.0-dev.2534
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 +6 -2
- package/dist/facade.js +6 -2
- package/dist/terminal-internal.cjs +11 -2
- package/dist/terminal-internal.js +11 -2
- package/dist/terminal.cjs +1 -2
- package/dist/terminal.js +1 -2
- package/dist/usage.cjs +4 -0
- package/dist/usage.d.cts +4 -0
- package/dist/usage.d.ts +4 -0
- package/dist/usage.js +4 -0
- package/package.json +2 -2
package/dist/facade.cjs
CHANGED
|
@@ -533,7 +533,8 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
|
|
|
533
533
|
const error = require_message.message`Missing shell name for completion.`;
|
|
534
534
|
stderr(`${errorLabel()}${formatMessage(error, {
|
|
535
535
|
colors,
|
|
536
|
-
quotes: !colors
|
|
536
|
+
quotes: !colors,
|
|
537
|
+
maxWidth
|
|
537
538
|
})}\n`);
|
|
538
539
|
if (completionParser) {
|
|
539
540
|
const displayName = isOptionMode ? completionOptionDisplayName ?? "--completion" : completionCommandDisplayName ?? "completion";
|
|
@@ -564,7 +565,8 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
|
|
|
564
565
|
const error = require_message.message`Unsupported shell ${shellName}. Available shells: ${available}.`;
|
|
565
566
|
stderr(`${errorLabel()}${formatMessage(error, {
|
|
566
567
|
colors,
|
|
567
|
-
quotes: !colors
|
|
568
|
+
quotes: !colors,
|
|
569
|
+
maxWidth
|
|
568
570
|
})}`);
|
|
569
571
|
return require_mode_dispatch.dispatchByMode(parser.mode, () => {
|
|
570
572
|
const result = callOnError(1, error);
|
|
@@ -1052,6 +1054,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1052
1054
|
expandCommands: true
|
|
1053
1055
|
}), usageLabelWidth())}`);
|
|
1054
1056
|
const errorMessage = formatMessage(validationError, {
|
|
1057
|
+
maxWidth,
|
|
1055
1058
|
colors,
|
|
1056
1059
|
quotes: !colors
|
|
1057
1060
|
});
|
|
@@ -1169,6 +1172,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1169
1172
|
expandCommands: true
|
|
1170
1173
|
}), usageLabelWidth())}`);
|
|
1171
1174
|
const errorMessage = formatMessage(classified.error, {
|
|
1175
|
+
maxWidth,
|
|
1172
1176
|
colors,
|
|
1173
1177
|
quotes: !colors
|
|
1174
1178
|
});
|
package/dist/facade.js
CHANGED
|
@@ -533,7 +533,8 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
|
|
|
533
533
|
const error = message`Missing shell name for completion.`;
|
|
534
534
|
stderr(`${errorLabel()}${formatMessage(error, {
|
|
535
535
|
colors,
|
|
536
|
-
quotes: !colors
|
|
536
|
+
quotes: !colors,
|
|
537
|
+
maxWidth
|
|
537
538
|
})}\n`);
|
|
538
539
|
if (completionParser) {
|
|
539
540
|
const displayName = isOptionMode ? completionOptionDisplayName ?? "--completion" : completionCommandDisplayName ?? "completion";
|
|
@@ -564,7 +565,8 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
|
|
|
564
565
|
const error = message`Unsupported shell ${shellName}. Available shells: ${available}.`;
|
|
565
566
|
stderr(`${errorLabel()}${formatMessage(error, {
|
|
566
567
|
colors,
|
|
567
|
-
quotes: !colors
|
|
568
|
+
quotes: !colors,
|
|
569
|
+
maxWidth
|
|
568
570
|
})}`);
|
|
569
571
|
return dispatchByMode(parser.mode, () => {
|
|
570
572
|
const result = callOnError(1, error);
|
|
@@ -1052,6 +1054,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1052
1054
|
expandCommands: true
|
|
1053
1055
|
}), usageLabelWidth())}`);
|
|
1054
1056
|
const errorMessage = formatMessage(validationError, {
|
|
1057
|
+
maxWidth,
|
|
1055
1058
|
colors,
|
|
1056
1059
|
quotes: !colors
|
|
1057
1060
|
});
|
|
@@ -1169,6 +1172,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1169
1172
|
expandCommands: true
|
|
1170
1173
|
}), usageLabelWidth())}`);
|
|
1171
1174
|
const errorMessage = formatMessage(classified.error, {
|
|
1175
|
+
maxWidth,
|
|
1172
1176
|
colors,
|
|
1173
1177
|
quotes: !colors
|
|
1174
1178
|
});
|
|
@@ -8,6 +8,15 @@ function terminalText(text) {
|
|
|
8
8
|
text
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
+
function valuesFormatter(theme) {
|
|
12
|
+
if (theme.values != null && theme.values !== require_terminal.defaultTerminalTheme.values) return theme.values;
|
|
13
|
+
if (theme.value != null && theme.value !== require_terminal.defaultTerminalTheme.value) return require_terminal.defaultTerminalTheme.values;
|
|
14
|
+
return (term, context) => ({
|
|
15
|
+
type: "style",
|
|
16
|
+
style: { foreground: "green" },
|
|
17
|
+
children: [require_terminal.defaultTerminalTheme.values(term, context)]
|
|
18
|
+
});
|
|
19
|
+
}
|
|
11
20
|
function formatTerminalTerm(term, theme = {}, quotes = false, usage) {
|
|
12
21
|
const quote = (s) => quotes ? `\`${s}\`` : s;
|
|
13
22
|
let text;
|
|
@@ -61,7 +70,7 @@ function formatTerminalTerm(term, theme = {}, quotes = false, usage) {
|
|
|
61
70
|
case "optionNames": return (theme.optionNames ?? require_terminal.defaultTerminalTheme.optionNames)(term, ctx);
|
|
62
71
|
case "metavar": return (theme.metavar ?? require_terminal.defaultTerminalTheme.metavar)(term, ctx);
|
|
63
72
|
case "value": return (theme.value ?? require_terminal.defaultTerminalTheme.value)(term, ctx);
|
|
64
|
-
case "values": return (theme
|
|
73
|
+
case "values": return valuesFormatter(theme)(term, ctx);
|
|
65
74
|
case "envVar": return (theme.envVar ?? require_terminal.defaultTerminalTheme.envVar)(term, ctx);
|
|
66
75
|
case "commandLine": return (theme.commandLine ?? require_terminal.defaultTerminalTheme.commandLine)(term, ctx);
|
|
67
76
|
case "url": return (theme.url ?? require_terminal.defaultTerminalTheme.url)(term, ctx);
|
|
@@ -234,7 +243,7 @@ function cacheTerminalTheme(theme = {}) {
|
|
|
234
243
|
optionNames: cache(theme.optionNames ?? require_terminal.defaultTerminalTheme.optionNames),
|
|
235
244
|
metavar: cache(theme.metavar ?? require_terminal.defaultTerminalTheme.metavar),
|
|
236
245
|
value: cache(theme.value ?? require_terminal.defaultTerminalTheme.value),
|
|
237
|
-
values: cache(theme
|
|
246
|
+
values: cache(valuesFormatter(theme)),
|
|
238
247
|
envVar: cache(theme.envVar ?? require_terminal.defaultTerminalTheme.envVar),
|
|
239
248
|
commandLine: cache(theme.commandLine ?? require_terminal.defaultTerminalTheme.commandLine),
|
|
240
249
|
url: cache(theme.url ?? require_terminal.defaultTerminalTheme.url),
|
|
@@ -8,6 +8,15 @@ function terminalText(text) {
|
|
|
8
8
|
text
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
+
function valuesFormatter(theme) {
|
|
12
|
+
if (theme.values != null && theme.values !== defaultTerminalTheme.values) return theme.values;
|
|
13
|
+
if (theme.value != null && theme.value !== defaultTerminalTheme.value) return defaultTerminalTheme.values;
|
|
14
|
+
return (term, context) => ({
|
|
15
|
+
type: "style",
|
|
16
|
+
style: { foreground: "green" },
|
|
17
|
+
children: [defaultTerminalTheme.values(term, context)]
|
|
18
|
+
});
|
|
19
|
+
}
|
|
11
20
|
function formatTerminalTerm(term, theme = {}, quotes = false, usage) {
|
|
12
21
|
const quote = (s) => quotes ? `\`${s}\`` : s;
|
|
13
22
|
let text;
|
|
@@ -61,7 +70,7 @@ function formatTerminalTerm(term, theme = {}, quotes = false, usage) {
|
|
|
61
70
|
case "optionNames": return (theme.optionNames ?? defaultTerminalTheme.optionNames)(term, ctx);
|
|
62
71
|
case "metavar": return (theme.metavar ?? defaultTerminalTheme.metavar)(term, ctx);
|
|
63
72
|
case "value": return (theme.value ?? defaultTerminalTheme.value)(term, ctx);
|
|
64
|
-
case "values": return (theme
|
|
73
|
+
case "values": return valuesFormatter(theme)(term, ctx);
|
|
65
74
|
case "envVar": return (theme.envVar ?? defaultTerminalTheme.envVar)(term, ctx);
|
|
66
75
|
case "commandLine": return (theme.commandLine ?? defaultTerminalTheme.commandLine)(term, ctx);
|
|
67
76
|
case "url": return (theme.url ?? defaultTerminalTheme.url)(term, ctx);
|
|
@@ -234,7 +243,7 @@ function cacheTerminalTheme(theme = {}) {
|
|
|
234
243
|
optionNames: cache(theme.optionNames ?? defaultTerminalTheme.optionNames),
|
|
235
244
|
metavar: cache(theme.metavar ?? defaultTerminalTheme.metavar),
|
|
236
245
|
value: cache(theme.value ?? defaultTerminalTheme.value),
|
|
237
|
-
values: cache(theme
|
|
246
|
+
values: cache(valuesFormatter(theme)),
|
|
238
247
|
envVar: cache(theme.envVar ?? defaultTerminalTheme.envVar),
|
|
239
248
|
commandLine: cache(theme.commandLine ?? defaultTerminalTheme.commandLine),
|
|
240
249
|
url: cache(theme.url ?? defaultTerminalTheme.url),
|
package/dist/terminal.cjs
CHANGED
|
@@ -33,8 +33,7 @@ const defaultTerminalTheme = {
|
|
|
33
33
|
} : styled(ctx.text, ctx.usage === "argument" ? { underline: true } : { bold: true }),
|
|
34
34
|
value: (_term, ctx) => ctx.usage === "literal" ? plain(ctx.text) : styled(ctx.text, { foreground: "green" }),
|
|
35
35
|
values: (term, ctx) => ({
|
|
36
|
-
type: "
|
|
37
|
-
style: { foreground: "green" },
|
|
36
|
+
type: "concat",
|
|
38
37
|
children: term.values.flatMap((value, i) => [...i === 0 ? [] : [plain(" ")], ctx.format({
|
|
39
38
|
type: "value",
|
|
40
39
|
value
|
package/dist/terminal.js
CHANGED
|
@@ -32,8 +32,7 @@ const defaultTerminalTheme = {
|
|
|
32
32
|
} : styled(ctx.text, ctx.usage === "argument" ? { underline: true } : { bold: true }),
|
|
33
33
|
value: (_term, ctx) => ctx.usage === "literal" ? plain(ctx.text) : styled(ctx.text, { foreground: "green" }),
|
|
34
34
|
values: (term, ctx) => ({
|
|
35
|
-
type: "
|
|
36
|
-
style: { foreground: "green" },
|
|
35
|
+
type: "concat",
|
|
37
36
|
children: term.values.flatMap((value, i) => [...i === 0 ? [] : [plain(" ")], ctx.format({
|
|
38
37
|
type: "value",
|
|
39
38
|
value
|
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 = {
|
|
@@ -468,6 +470,8 @@ function* formatUsageTerms(terms, options) {
|
|
|
468
470
|
* @param options Optional formatting options to customize the output.
|
|
469
471
|
* See {@link UsageTermFormatOptions} for available options.
|
|
470
472
|
* @returns A formatted string representation of the usage term.
|
|
473
|
+
* @throws {RangeError} If a theme supplies an invalid RGB channel or palette
|
|
474
|
+
* index, even when colors are disabled.
|
|
471
475
|
*/
|
|
472
476
|
function formatUsageTerm(term, options = {}) {
|
|
473
477
|
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
|
/**
|
|
@@ -483,6 +485,8 @@ interface UsageTermFormatOptions extends UsageFormatOptions {
|
|
|
483
485
|
* @param options Optional formatting options to customize the output.
|
|
484
486
|
* See {@link UsageTermFormatOptions} for available options.
|
|
485
487
|
* @returns A formatted string representation of the usage term.
|
|
488
|
+
* @throws {RangeError} If a theme supplies an invalid RGB channel or palette
|
|
489
|
+
* index, even when colors are disabled.
|
|
486
490
|
*/
|
|
487
491
|
declare function formatUsageTerm(term: UsageTerm, options?: UsageTermFormatOptions): string;
|
|
488
492
|
//#endregion
|
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
|
/**
|
|
@@ -483,6 +485,8 @@ interface UsageTermFormatOptions extends UsageFormatOptions {
|
|
|
483
485
|
* @param options Optional formatting options to customize the output.
|
|
484
486
|
* See {@link UsageTermFormatOptions} for available options.
|
|
485
487
|
* @returns A formatted string representation of the usage term.
|
|
488
|
+
* @throws {RangeError} If a theme supplies an invalid RGB channel or palette
|
|
489
|
+
* index, even when colors are disabled.
|
|
486
490
|
*/
|
|
487
491
|
declare function formatUsageTerm(term: UsageTerm, options?: UsageTermFormatOptions): string;
|
|
488
492
|
//#endregion
|
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 = {
|
|
@@ -468,6 +470,8 @@ function* formatUsageTerms(terms, options) {
|
|
|
468
470
|
* @param options Optional formatting options to customize the output.
|
|
469
471
|
* See {@link UsageTermFormatOptions} for available options.
|
|
470
472
|
* @returns A formatted string representation of the usage term.
|
|
473
|
+
* @throws {RangeError} If a theme supplies an invalid RGB channel or palette
|
|
474
|
+
* index, even when colors are disabled.
|
|
471
475
|
*/
|
|
472
476
|
function formatUsageTerm(term, options = {}) {
|
|
473
477
|
options = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/core",
|
|
3
|
-
"version": "1.3.0-dev.
|
|
3
|
+
"version": "1.3.0-dev.2534",
|
|
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.
|
|
240
|
+
"@optique/env": "1.3.0-dev.2534+0daf40ee",
|
|
241
241
|
"@types/node": "^24.0.0",
|
|
242
242
|
"fast-check": "^4.7.0",
|
|
243
243
|
"tsdown": "^0.13.0",
|