@optique/core 1.0.0-dev.1299 → 1.0.0-dev.1303

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
@@ -87,24 +87,20 @@ function formatDocPage(programName, page, options = {}) {
87
87
  ...page,
88
88
  sections: filteredSections
89
89
  };
90
+ const hasContent = (msg) => Array.isArray(msg) && msg.length > 0;
90
91
  if (options.maxWidth != null) {
91
92
  const hasEntries = page.sections.some((s) => s.entries.length > 0);
92
- const hasContent = (msg) => Array.isArray(msg) && msg.length > 0;
93
- const needsDescColumn = hasEntries && page.sections.some((s) => s.entries.some((e) => hasContent(e.description) || options.showDefault && e.default != null || options.showChoices && e.choices != null));
93
+ const needsDescColumn = hasEntries && page.sections.some((s) => s.entries.some((e) => hasContent(e.description) || options.showDefault && hasContent(e.default) || options.showChoices && hasContent(e.choices)));
94
94
  let minDescWidth = 1;
95
95
  if (needsDescColumn) {
96
- if (options.showDefault && page.sections.some((s) => s.entries.some((e) => e.default != null))) {
96
+ if (options.showDefault && page.sections.some((s) => s.entries.some((e) => hasContent(e.default)))) {
97
97
  const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
98
- const suffix = typeof options.showDefault === "object" ? options.showDefault.suffix ?? "]" : "]";
99
- const hasEmptyDefault = page.sections.some((s) => s.entries.some((e) => e.default != null && Array.isArray(e.default) && e.default.length === 0));
100
- minDescWidth = Math.max(minDescWidth, hasEmptyDefault ? prefix.length + suffix.length : prefix.length);
98
+ minDescWidth = Math.max(minDescWidth, prefix.length);
101
99
  }
102
- if (options.showChoices && page.sections.some((s) => s.entries.some((e) => e.choices != null))) {
100
+ if (options.showChoices && page.sections.some((s) => s.entries.some((e) => hasContent(e.choices)))) {
103
101
  const prefix = typeof options.showChoices === "object" ? options.showChoices.prefix ?? " (" : " (";
104
- const suffix = typeof options.showChoices === "object" ? options.showChoices.suffix ?? ")" : ")";
105
102
  const label = typeof options.showChoices === "object" ? options.showChoices.label ?? "choices: " : "choices: ";
106
- const hasEmptyChoices = page.sections.some((s) => s.entries.some((e) => e.choices != null && Array.isArray(e.choices) && e.choices.length === 0));
107
- minDescWidth = Math.max(minDescWidth, hasEmptyChoices ? prefix.length + label.length + suffix.length : prefix.length + label.length);
103
+ minDescWidth = Math.max(minDescWidth, prefix.length + label.length);
108
104
  }
109
105
  }
110
106
  const splitEntryMin = termIndent + 2 + Math.max(2, 2 * minDescWidth - 1);
@@ -196,7 +192,7 @@ function formatDocPage(programName, page, options = {}) {
196
192
  startWidth: extraTermOffset > 0 ? extraTermOffset : void 0
197
193
  };
198
194
  let description = entry.description == null ? "" : require_message.formatMessage(entry.description, descFormatOptions);
199
- if (options.showDefault && entry.default != null) {
195
+ if (options.showDefault && hasContent(entry.default)) {
200
196
  const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
201
197
  const suffix = typeof options.showDefault === "object" ? options.showDefault.suffix ?? "]" : "]";
202
198
  let defaultStartWidth;
@@ -219,7 +215,7 @@ function formatDocPage(programName, page, options = {}) {
219
215
  const formattedDefault = options.colors ? `\x1b[2m${defaultText}\x1b[0m` : defaultText;
220
216
  description += formattedDefault;
221
217
  }
222
- if (options.showChoices && entry.choices != null) {
218
+ if (options.showChoices && hasContent(entry.choices)) {
223
219
  const prefix = typeof options.showChoices === "object" ? options.showChoices.prefix ?? " (" : " (";
224
220
  const suffix = typeof options.showChoices === "object" ? options.showChoices.suffix ?? ")" : ")";
225
221
  const label = typeof options.showChoices === "object" ? options.showChoices.label ?? "choices: " : "choices: ";
package/dist/doc.js CHANGED
@@ -87,24 +87,20 @@ function formatDocPage(programName, page, options = {}) {
87
87
  ...page,
88
88
  sections: filteredSections
89
89
  };
90
+ const hasContent = (msg) => Array.isArray(msg) && msg.length > 0;
90
91
  if (options.maxWidth != null) {
91
92
  const hasEntries = page.sections.some((s) => s.entries.length > 0);
92
- const hasContent = (msg) => Array.isArray(msg) && msg.length > 0;
93
- const needsDescColumn = hasEntries && page.sections.some((s) => s.entries.some((e) => hasContent(e.description) || options.showDefault && e.default != null || options.showChoices && e.choices != null));
93
+ const needsDescColumn = hasEntries && page.sections.some((s) => s.entries.some((e) => hasContent(e.description) || options.showDefault && hasContent(e.default) || options.showChoices && hasContent(e.choices)));
94
94
  let minDescWidth = 1;
95
95
  if (needsDescColumn) {
96
- if (options.showDefault && page.sections.some((s) => s.entries.some((e) => e.default != null))) {
96
+ if (options.showDefault && page.sections.some((s) => s.entries.some((e) => hasContent(e.default)))) {
97
97
  const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
98
- const suffix = typeof options.showDefault === "object" ? options.showDefault.suffix ?? "]" : "]";
99
- const hasEmptyDefault = page.sections.some((s) => s.entries.some((e) => e.default != null && Array.isArray(e.default) && e.default.length === 0));
100
- minDescWidth = Math.max(minDescWidth, hasEmptyDefault ? prefix.length + suffix.length : prefix.length);
98
+ minDescWidth = Math.max(minDescWidth, prefix.length);
101
99
  }
102
- if (options.showChoices && page.sections.some((s) => s.entries.some((e) => e.choices != null))) {
100
+ if (options.showChoices && page.sections.some((s) => s.entries.some((e) => hasContent(e.choices)))) {
103
101
  const prefix = typeof options.showChoices === "object" ? options.showChoices.prefix ?? " (" : " (";
104
- const suffix = typeof options.showChoices === "object" ? options.showChoices.suffix ?? ")" : ")";
105
102
  const label = typeof options.showChoices === "object" ? options.showChoices.label ?? "choices: " : "choices: ";
106
- const hasEmptyChoices = page.sections.some((s) => s.entries.some((e) => e.choices != null && Array.isArray(e.choices) && e.choices.length === 0));
107
- minDescWidth = Math.max(minDescWidth, hasEmptyChoices ? prefix.length + label.length + suffix.length : prefix.length + label.length);
103
+ minDescWidth = Math.max(minDescWidth, prefix.length + label.length);
108
104
  }
109
105
  }
110
106
  const splitEntryMin = termIndent + 2 + Math.max(2, 2 * minDescWidth - 1);
@@ -196,7 +192,7 @@ function formatDocPage(programName, page, options = {}) {
196
192
  startWidth: extraTermOffset > 0 ? extraTermOffset : void 0
197
193
  };
198
194
  let description = entry.description == null ? "" : formatMessage(entry.description, descFormatOptions);
199
- if (options.showDefault && entry.default != null) {
195
+ if (options.showDefault && hasContent(entry.default)) {
200
196
  const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
201
197
  const suffix = typeof options.showDefault === "object" ? options.showDefault.suffix ?? "]" : "]";
202
198
  let defaultStartWidth;
@@ -219,7 +215,7 @@ function formatDocPage(programName, page, options = {}) {
219
215
  const formattedDefault = options.colors ? `\x1b[2m${defaultText}\x1b[0m` : defaultText;
220
216
  description += formattedDefault;
221
217
  }
222
- if (options.showChoices && entry.choices != null) {
218
+ if (options.showChoices && hasContent(entry.choices)) {
223
219
  const prefix = typeof options.showChoices === "object" ? options.showChoices.prefix ?? " (" : " (";
224
220
  const suffix = typeof options.showChoices === "object" ? options.showChoices.suffix ?? ")" : ")";
225
221
  const label = typeof options.showChoices === "object" ? options.showChoices.label ?? "choices: " : "choices: ";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1299+1f63907e",
3
+ "version": "1.0.0-dev.1303+2bdb4aa1",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",