@optique/core 0.10.5 → 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 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
- let description = entry.description == null ? "" : require_message.formatMessage(entry.description, {
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
- if (lastW + prefix.length >= descColumnWidth) {
98
+ const effectiveLastW = lastW + currentExtraOffset();
99
+ if (effectiveLastW + prefix.length >= descColumnWidth) {
94
100
  description += "\n";
95
101
  defaultStartWidth = prefix.length;
96
- } else defaultStartWidth = lastW + prefix.length;
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 (lastW + prefixLabelLen >= descColumnWidth) {
141
+ if (effectiveLastW + prefixLabelLen >= descColumnWidth) {
135
142
  description += "\n";
136
143
  choicesStartWidth = prefixLabelLen;
137
- } else choicesStartWidth = lastW + prefixLabelLen;
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
- let description = entry.description == null ? "" : formatMessage(entry.description, {
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
- if (lastW + prefix.length >= descColumnWidth) {
98
+ const effectiveLastW = lastW + currentExtraOffset();
99
+ if (effectiveLastW + prefix.length >= descColumnWidth) {
94
100
  description += "\n";
95
101
  defaultStartWidth = prefix.length;
96
- } else defaultStartWidth = lastW + prefix.length;
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 (lastW + prefixLabelLen >= descColumnWidth) {
141
+ if (effectiveLastW + prefixLabelLen >= descColumnWidth) {
135
142
  description += "\n";
136
143
  choicesStartWidth = prefixLabelLen;
137
- } else choicesStartWidth = lastW + prefixLabelLen;
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "0.10.5",
3
+ "version": "0.10.6-dev.424+53b58708",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",