@optique/core 0.10.5-dev.417 → 0.10.6-dev.424
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 +16 -9
- package/dist/doc.js +16 -9
- package/dist/facade.cjs +6 -0
- package/dist/facade.js +6 -0
- package/package.json +1 -1
package/dist/doc.cjs
CHANGED
|
@@ -79,26 +79,32 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
79
79
|
maxWidth: options.maxWidth == null ? void 0 : options.maxWidth - termIndent
|
|
80
80
|
});
|
|
81
81
|
const descColumnWidth = options.maxWidth == null ? void 0 : options.maxWidth - termIndent - termWidth - 2;
|
|
82
|
-
|
|
82
|
+
const termVisibleWidth = lastLineVisibleLength(term);
|
|
83
|
+
const extraTermOffset = descColumnWidth != null ? Math.max(0, termVisibleWidth - termWidth) : 0;
|
|
84
|
+
const currentExtraOffset = () => description.includes("\n") ? 0 : extraTermOffset;
|
|
85
|
+
const descFormatOptions = {
|
|
83
86
|
colors: options.colors,
|
|
84
87
|
quotes: !options.colors,
|
|
85
|
-
maxWidth: descColumnWidth
|
|
86
|
-
|
|
88
|
+
maxWidth: descColumnWidth,
|
|
89
|
+
startWidth: extraTermOffset > 0 ? extraTermOffset : void 0
|
|
90
|
+
};
|
|
91
|
+
let description = entry.description == null ? "" : require_message.formatMessage(entry.description, descFormatOptions);
|
|
87
92
|
if (options.showDefault && entry.default != null) {
|
|
88
93
|
const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
|
|
89
94
|
const suffix = typeof options.showDefault === "object" ? options.showDefault.suffix ?? "]" : "]";
|
|
90
95
|
let defaultStartWidth;
|
|
91
96
|
if (descColumnWidth != null) {
|
|
92
97
|
const lastW = lastLineVisibleLength(description);
|
|
93
|
-
|
|
98
|
+
const effectiveLastW = lastW + currentExtraOffset();
|
|
99
|
+
if (effectiveLastW + prefix.length >= descColumnWidth) {
|
|
94
100
|
description += "\n";
|
|
95
101
|
defaultStartWidth = prefix.length;
|
|
96
|
-
} else defaultStartWidth =
|
|
102
|
+
} else defaultStartWidth = effectiveLastW + prefix.length;
|
|
97
103
|
}
|
|
98
104
|
const defaultFormatOptions = {
|
|
99
105
|
colors: options.colors ? { resetSuffix: "\x1B[2m" } : false,
|
|
100
106
|
quotes: !options.colors,
|
|
101
|
-
maxWidth: descColumnWidth,
|
|
107
|
+
maxWidth: descColumnWidth == null ? void 0 : descColumnWidth - suffix.length,
|
|
102
108
|
startWidth: defaultStartWidth
|
|
103
109
|
};
|
|
104
110
|
const defaultContent = require_message.formatMessage(entry.default, defaultFormatOptions);
|
|
@@ -130,16 +136,17 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
130
136
|
let choicesStartWidth;
|
|
131
137
|
if (descColumnWidth != null) {
|
|
132
138
|
const lastW = lastLineVisibleLength(description);
|
|
139
|
+
const effectiveLastW = lastW + currentExtraOffset();
|
|
133
140
|
const prefixLabelLen = prefix.length + label.length;
|
|
134
|
-
if (
|
|
141
|
+
if (effectiveLastW + prefixLabelLen >= descColumnWidth) {
|
|
135
142
|
description += "\n";
|
|
136
143
|
choicesStartWidth = prefixLabelLen;
|
|
137
|
-
} else choicesStartWidth =
|
|
144
|
+
} else choicesStartWidth = effectiveLastW + prefixLabelLen;
|
|
138
145
|
}
|
|
139
146
|
const choicesFormatOptions = {
|
|
140
147
|
colors: options.colors ? { resetSuffix: "\x1B[2m" } : false,
|
|
141
148
|
quotes: false,
|
|
142
|
-
maxWidth: descColumnWidth,
|
|
149
|
+
maxWidth: descColumnWidth == null ? void 0 : descColumnWidth - suffix.length,
|
|
143
150
|
startWidth: choicesStartWidth
|
|
144
151
|
};
|
|
145
152
|
const choicesDisplay = require_message.formatMessage(truncatedTerms, choicesFormatOptions);
|
package/dist/doc.js
CHANGED
|
@@ -79,26 +79,32 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
79
79
|
maxWidth: options.maxWidth == null ? void 0 : options.maxWidth - termIndent
|
|
80
80
|
});
|
|
81
81
|
const descColumnWidth = options.maxWidth == null ? void 0 : options.maxWidth - termIndent - termWidth - 2;
|
|
82
|
-
|
|
82
|
+
const termVisibleWidth = lastLineVisibleLength(term);
|
|
83
|
+
const extraTermOffset = descColumnWidth != null ? Math.max(0, termVisibleWidth - termWidth) : 0;
|
|
84
|
+
const currentExtraOffset = () => description.includes("\n") ? 0 : extraTermOffset;
|
|
85
|
+
const descFormatOptions = {
|
|
83
86
|
colors: options.colors,
|
|
84
87
|
quotes: !options.colors,
|
|
85
|
-
maxWidth: descColumnWidth
|
|
86
|
-
|
|
88
|
+
maxWidth: descColumnWidth,
|
|
89
|
+
startWidth: extraTermOffset > 0 ? extraTermOffset : void 0
|
|
90
|
+
};
|
|
91
|
+
let description = entry.description == null ? "" : formatMessage(entry.description, descFormatOptions);
|
|
87
92
|
if (options.showDefault && entry.default != null) {
|
|
88
93
|
const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
|
|
89
94
|
const suffix = typeof options.showDefault === "object" ? options.showDefault.suffix ?? "]" : "]";
|
|
90
95
|
let defaultStartWidth;
|
|
91
96
|
if (descColumnWidth != null) {
|
|
92
97
|
const lastW = lastLineVisibleLength(description);
|
|
93
|
-
|
|
98
|
+
const effectiveLastW = lastW + currentExtraOffset();
|
|
99
|
+
if (effectiveLastW + prefix.length >= descColumnWidth) {
|
|
94
100
|
description += "\n";
|
|
95
101
|
defaultStartWidth = prefix.length;
|
|
96
|
-
} else defaultStartWidth =
|
|
102
|
+
} else defaultStartWidth = effectiveLastW + prefix.length;
|
|
97
103
|
}
|
|
98
104
|
const defaultFormatOptions = {
|
|
99
105
|
colors: options.colors ? { resetSuffix: "\x1B[2m" } : false,
|
|
100
106
|
quotes: !options.colors,
|
|
101
|
-
maxWidth: descColumnWidth,
|
|
107
|
+
maxWidth: descColumnWidth == null ? void 0 : descColumnWidth - suffix.length,
|
|
102
108
|
startWidth: defaultStartWidth
|
|
103
109
|
};
|
|
104
110
|
const defaultContent = formatMessage(entry.default, defaultFormatOptions);
|
|
@@ -130,16 +136,17 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
130
136
|
let choicesStartWidth;
|
|
131
137
|
if (descColumnWidth != null) {
|
|
132
138
|
const lastW = lastLineVisibleLength(description);
|
|
139
|
+
const effectiveLastW = lastW + currentExtraOffset();
|
|
133
140
|
const prefixLabelLen = prefix.length + label.length;
|
|
134
|
-
if (
|
|
141
|
+
if (effectiveLastW + prefixLabelLen >= descColumnWidth) {
|
|
135
142
|
description += "\n";
|
|
136
143
|
choicesStartWidth = prefixLabelLen;
|
|
137
|
-
} else choicesStartWidth =
|
|
144
|
+
} else choicesStartWidth = effectiveLastW + prefixLabelLen;
|
|
138
145
|
}
|
|
139
146
|
const choicesFormatOptions = {
|
|
140
147
|
colors: options.colors ? { resetSuffix: "\x1B[2m" } : false,
|
|
141
148
|
quotes: false,
|
|
142
|
-
maxWidth: descColumnWidth,
|
|
149
|
+
maxWidth: descColumnWidth == null ? void 0 : descColumnWidth - suffix.length,
|
|
143
150
|
startWidth: choicesStartWidth
|
|
144
151
|
};
|
|
145
152
|
const choicesDisplay = formatMessage(truncatedTerms, choicesFormatOptions);
|
package/dist/facade.cjs
CHANGED
|
@@ -542,6 +542,9 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
542
542
|
const helpAsCommand = help === "command" || help === "both";
|
|
543
543
|
const versionAsCommand = version === "command" || version === "both";
|
|
544
544
|
const completionAsCommand = completion === "command" || completion === "both";
|
|
545
|
+
const helpAsOption = help === "option" || help === "both";
|
|
546
|
+
const versionAsOption = version === "option" || version === "both";
|
|
547
|
+
const completionAsOption = completion === "option" || completion === "both";
|
|
545
548
|
const requestedCommand = classified.commands[0];
|
|
546
549
|
if ((requestedCommand === "completion" || requestedCommand === "completions") && completionAsCommand && completionParsers.completionCommand) helpGeneratorParser = completionParsers.completionCommand;
|
|
547
550
|
else if (requestedCommand === "help" && helpAsCommand && helpParsers.helpCommand) helpGeneratorParser = helpParsers.helpCommand;
|
|
@@ -560,6 +563,9 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
560
563
|
commandParsers.push(...ungroupedMeta);
|
|
561
564
|
for (const [label, parsers] of Object.entries(groupedMeta)) if (parsers.length === 1) commandParsers.push(require_constructs.group(label, parsers[0]));
|
|
562
565
|
else commandParsers.push(require_constructs.group(label, require_constructs.longestMatch(...parsers)));
|
|
566
|
+
if (helpAsOption && helpParsers.helpOption) commandParsers.push(helpParsers.helpOption);
|
|
567
|
+
if (versionAsOption && versionParsers.versionOption) commandParsers.push(versionParsers.versionOption);
|
|
568
|
+
if (completionAsOption && completionParsers.completionOption) commandParsers.push(completionParsers.completionOption);
|
|
563
569
|
if (commandParsers.length === 1) helpGeneratorParser = commandParsers[0];
|
|
564
570
|
else if (commandParsers.length === 2) helpGeneratorParser = require_constructs.longestMatch(commandParsers[0], commandParsers[1]);
|
|
565
571
|
else helpGeneratorParser = require_constructs.longestMatch(...commandParsers);
|
package/dist/facade.js
CHANGED
|
@@ -542,6 +542,9 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
542
542
|
const helpAsCommand = help === "command" || help === "both";
|
|
543
543
|
const versionAsCommand = version === "command" || version === "both";
|
|
544
544
|
const completionAsCommand = completion === "command" || completion === "both";
|
|
545
|
+
const helpAsOption = help === "option" || help === "both";
|
|
546
|
+
const versionAsOption = version === "option" || version === "both";
|
|
547
|
+
const completionAsOption = completion === "option" || completion === "both";
|
|
545
548
|
const requestedCommand = classified.commands[0];
|
|
546
549
|
if ((requestedCommand === "completion" || requestedCommand === "completions") && completionAsCommand && completionParsers.completionCommand) helpGeneratorParser = completionParsers.completionCommand;
|
|
547
550
|
else if (requestedCommand === "help" && helpAsCommand && helpParsers.helpCommand) helpGeneratorParser = helpParsers.helpCommand;
|
|
@@ -560,6 +563,9 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
560
563
|
commandParsers.push(...ungroupedMeta);
|
|
561
564
|
for (const [label, parsers] of Object.entries(groupedMeta)) if (parsers.length === 1) commandParsers.push(group(label, parsers[0]));
|
|
562
565
|
else commandParsers.push(group(label, longestMatch(...parsers)));
|
|
566
|
+
if (helpAsOption && helpParsers.helpOption) commandParsers.push(helpParsers.helpOption);
|
|
567
|
+
if (versionAsOption && versionParsers.versionOption) commandParsers.push(versionParsers.versionOption);
|
|
568
|
+
if (completionAsOption && completionParsers.completionOption) commandParsers.push(completionParsers.completionOption);
|
|
563
569
|
if (commandParsers.length === 1) helpGeneratorParser = commandParsers[0];
|
|
564
570
|
else if (commandParsers.length === 2) helpGeneratorParser = longestMatch(commandParsers[0], commandParsers[1]);
|
|
565
571
|
else helpGeneratorParser = longestMatch(...commandParsers);
|