@optique/core 0.4.0-dev.53 → 0.4.0-dev.55
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 +10 -2
- package/dist/doc.d.cts +44 -1
- package/dist/doc.d.ts +44 -1
- package/dist/doc.js +10 -2
- package/dist/facade.cjs +304 -251
- package/dist/facade.d.cts +13 -0
- package/dist/facade.d.ts +13 -0
- package/dist/facade.js +305 -252
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/doc.cjs
CHANGED
|
@@ -73,11 +73,19 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
73
73
|
optionsSeparator: ", ",
|
|
74
74
|
maxWidth: options.maxWidth == null ? void 0 : options.maxWidth - termIndent
|
|
75
75
|
});
|
|
76
|
-
|
|
76
|
+
let description = entry.description == null ? "" : require_message.formatMessage(entry.description, {
|
|
77
77
|
colors: options.colors,
|
|
78
78
|
quotes: !options.colors,
|
|
79
79
|
maxWidth: options.maxWidth == null ? void 0 : options.maxWidth - termIndent - termWidth - 2
|
|
80
|
-
})
|
|
80
|
+
});
|
|
81
|
+
if (options.showDefault && entry.default != null) {
|
|
82
|
+
const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
|
|
83
|
+
const suffix = typeof options.showDefault === "object" ? options.showDefault.suffix ?? "]" : "]";
|
|
84
|
+
const defaultText = `${prefix}${entry.default}${suffix}`;
|
|
85
|
+
const formattedDefault = options.colors ? `\x1b[2m${defaultText}\x1b[0m` : defaultText;
|
|
86
|
+
description += formattedDefault;
|
|
87
|
+
}
|
|
88
|
+
output += `${" ".repeat(termIndent)}${ansiAwareRightPad(term, termWidth)} ${description === "" ? "" : indentLines(description, termIndent + termWidth + 2)}\n`;
|
|
81
89
|
}
|
|
82
90
|
}
|
|
83
91
|
if (page.footer != null) {
|
package/dist/doc.d.cts
CHANGED
|
@@ -69,6 +69,25 @@ interface DocFragments {
|
|
|
69
69
|
*/
|
|
70
70
|
readonly fragments: readonly DocFragment[];
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Configuration for customizing default value display formatting.
|
|
74
|
+
*
|
|
75
|
+
* @since 0.4.0
|
|
76
|
+
*/
|
|
77
|
+
interface ShowDefaultOptions {
|
|
78
|
+
/**
|
|
79
|
+
* Text to display before the default value.
|
|
80
|
+
*
|
|
81
|
+
* @default `" ["`
|
|
82
|
+
*/
|
|
83
|
+
readonly prefix?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Text to display after the default value.
|
|
86
|
+
*
|
|
87
|
+
* @default `"]"`
|
|
88
|
+
*/
|
|
89
|
+
readonly suffix?: string;
|
|
90
|
+
}
|
|
72
91
|
/**
|
|
73
92
|
* Options for formatting a documentation page.
|
|
74
93
|
*/
|
|
@@ -92,6 +111,30 @@ interface DocPageFormatOptions {
|
|
|
92
111
|
* Maximum width of the entire formatted output.
|
|
93
112
|
*/
|
|
94
113
|
maxWidth?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Whether and how to display default values for options and arguments.
|
|
116
|
+
*
|
|
117
|
+
* - `boolean`: When `true`, displays defaults using format `[value]`
|
|
118
|
+
* - `ShowDefaultOptions`: Custom formatting with configurable prefix and suffix
|
|
119
|
+
*
|
|
120
|
+
* Default values are automatically dimmed when `colors` is enabled.
|
|
121
|
+
*
|
|
122
|
+
* @default `false`
|
|
123
|
+
* @since 0.4.0
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* // Basic usage - shows "[3000]"
|
|
128
|
+
* { showDefault: true }
|
|
129
|
+
*
|
|
130
|
+
* // Custom format - shows "(default: 3000)"
|
|
131
|
+
* { showDefault: { prefix: " (default: ", suffix: ")" } }
|
|
132
|
+
*
|
|
133
|
+
* // Custom format - shows " - defaults to 3000"
|
|
134
|
+
* { showDefault: { prefix: " - defaults to ", suffix: "" } }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
showDefault?: boolean | ShowDefaultOptions;
|
|
95
138
|
}
|
|
96
139
|
/**
|
|
97
140
|
* Formats a documentation page into a human-readable string.
|
|
@@ -126,4 +169,4 @@ interface DocPageFormatOptions {
|
|
|
126
169
|
*/
|
|
127
170
|
declare function formatDocPage(programName: string, page: DocPage, options?: DocPageFormatOptions): string;
|
|
128
171
|
//#endregion
|
|
129
|
-
export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, formatDocPage };
|
|
172
|
+
export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowDefaultOptions, formatDocPage };
|
package/dist/doc.d.ts
CHANGED
|
@@ -69,6 +69,25 @@ interface DocFragments {
|
|
|
69
69
|
*/
|
|
70
70
|
readonly fragments: readonly DocFragment[];
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Configuration for customizing default value display formatting.
|
|
74
|
+
*
|
|
75
|
+
* @since 0.4.0
|
|
76
|
+
*/
|
|
77
|
+
interface ShowDefaultOptions {
|
|
78
|
+
/**
|
|
79
|
+
* Text to display before the default value.
|
|
80
|
+
*
|
|
81
|
+
* @default `" ["`
|
|
82
|
+
*/
|
|
83
|
+
readonly prefix?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Text to display after the default value.
|
|
86
|
+
*
|
|
87
|
+
* @default `"]"`
|
|
88
|
+
*/
|
|
89
|
+
readonly suffix?: string;
|
|
90
|
+
}
|
|
72
91
|
/**
|
|
73
92
|
* Options for formatting a documentation page.
|
|
74
93
|
*/
|
|
@@ -92,6 +111,30 @@ interface DocPageFormatOptions {
|
|
|
92
111
|
* Maximum width of the entire formatted output.
|
|
93
112
|
*/
|
|
94
113
|
maxWidth?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Whether and how to display default values for options and arguments.
|
|
116
|
+
*
|
|
117
|
+
* - `boolean`: When `true`, displays defaults using format `[value]`
|
|
118
|
+
* - `ShowDefaultOptions`: Custom formatting with configurable prefix and suffix
|
|
119
|
+
*
|
|
120
|
+
* Default values are automatically dimmed when `colors` is enabled.
|
|
121
|
+
*
|
|
122
|
+
* @default `false`
|
|
123
|
+
* @since 0.4.0
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* // Basic usage - shows "[3000]"
|
|
128
|
+
* { showDefault: true }
|
|
129
|
+
*
|
|
130
|
+
* // Custom format - shows "(default: 3000)"
|
|
131
|
+
* { showDefault: { prefix: " (default: ", suffix: ")" } }
|
|
132
|
+
*
|
|
133
|
+
* // Custom format - shows " - defaults to 3000"
|
|
134
|
+
* { showDefault: { prefix: " - defaults to ", suffix: "" } }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
showDefault?: boolean | ShowDefaultOptions;
|
|
95
138
|
}
|
|
96
139
|
/**
|
|
97
140
|
* Formats a documentation page into a human-readable string.
|
|
@@ -126,4 +169,4 @@ interface DocPageFormatOptions {
|
|
|
126
169
|
*/
|
|
127
170
|
declare function formatDocPage(programName: string, page: DocPage, options?: DocPageFormatOptions): string;
|
|
128
171
|
//#endregion
|
|
129
|
-
export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, formatDocPage };
|
|
172
|
+
export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowDefaultOptions, formatDocPage };
|
package/dist/doc.js
CHANGED
|
@@ -73,11 +73,19 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
73
73
|
optionsSeparator: ", ",
|
|
74
74
|
maxWidth: options.maxWidth == null ? void 0 : options.maxWidth - termIndent
|
|
75
75
|
});
|
|
76
|
-
|
|
76
|
+
let description = entry.description == null ? "" : formatMessage(entry.description, {
|
|
77
77
|
colors: options.colors,
|
|
78
78
|
quotes: !options.colors,
|
|
79
79
|
maxWidth: options.maxWidth == null ? void 0 : options.maxWidth - termIndent - termWidth - 2
|
|
80
|
-
})
|
|
80
|
+
});
|
|
81
|
+
if (options.showDefault && entry.default != null) {
|
|
82
|
+
const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
|
|
83
|
+
const suffix = typeof options.showDefault === "object" ? options.showDefault.suffix ?? "]" : "]";
|
|
84
|
+
const defaultText = `${prefix}${entry.default}${suffix}`;
|
|
85
|
+
const formattedDefault = options.colors ? `\x1b[2m${defaultText}\x1b[0m` : defaultText;
|
|
86
|
+
description += formattedDefault;
|
|
87
|
+
}
|
|
88
|
+
output += `${" ".repeat(termIndent)}${ansiAwareRightPad(term, termWidth)} ${description === "" ? "" : indentLines(description, termIndent + termWidth + 2)}\n`;
|
|
81
89
|
}
|
|
82
90
|
}
|
|
83
91
|
if (page.footer != null) {
|