talented-args 0.2.4-beta → 0.3.0-beta
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/README.md +497 -10
- package/dist/clipboard.d.ts +10 -0
- package/dist/clipboard.js +79 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/compile.d.ts +67 -0
- package/dist/compile.js +188 -0
- package/dist/compile.js.map +1 -0
- package/dist/descriptors.d.ts +322 -0
- package/dist/descriptors.js +362 -0
- package/dist/descriptors.js.map +1 -0
- package/dist/display.d.ts +31 -0
- package/dist/display.js +235 -0
- package/dist/display.js.map +1 -0
- package/dist/errors.d.ts +34 -17
- package/dist/errors.js +61 -75
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +10 -6
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/options.d.ts +69 -37
- package/dist/options.js +198 -31
- package/dist/options.js.map +1 -1
- package/dist/parse.d.ts +70 -0
- package/dist/parse.js +551 -0
- package/dist/parse.js.map +1 -0
- package/dist/program.d.ts +125 -0
- package/dist/program.js +337 -0
- package/dist/program.js.map +1 -0
- package/dist/remember.d.ts +71 -0
- package/dist/remember.js +216 -0
- package/dist/remember.js.map +1 -0
- package/dist/styling.d.ts +38 -9
- package/dist/styling.js +155 -75
- package/dist/styling.js.map +1 -1
- package/dist/terminal.d.ts +205 -0
- package/dist/terminal.js +152 -0
- package/dist/terminal.js.map +1 -0
- package/dist/tools.d.ts +35 -31
- package/dist/tools.js +68 -140
- package/dist/tools.js.map +1 -1
- package/dist/tui.d.ts +96 -0
- package/dist/tui.js +397 -0
- package/dist/tui.js.map +1 -0
- package/dist/tui_layout.d.ts +152 -0
- package/dist/tui_layout.js +554 -0
- package/dist/tui_layout.js.map +1 -0
- package/dist/tui_model.d.ts +149 -0
- package/dist/tui_model.js +666 -0
- package/dist/tui_model.js.map +1 -0
- package/package.json +18 -14
- package/.eslintrc.js +0 -24
- package/.idea/codeStyles/Project.xml +0 -364
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/compiler.xml +0 -7
- package/.idea/encodings.xml +0 -6
- package/.idea/inspectionProfiles/Project_Default.xml +0 -12
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/prettier.xml +0 -8
- package/.idea/talented-args.iml +0 -11
- package/.idea/vcs.xml +0 -6
- package/.prettierrc.yaml +0 -4
- package/dist/definitions.d.ts +0 -70
- package/dist/definitions.js +0 -38
- package/dist/definitions.js.map +0 -1
- package/dist/main.d.ts +0 -33
- package/dist/main.js +0 -313
- package/dist/main.js.map +0 -1
- package/jest.config.js +0 -4
- package/tsconfig.json +0 -18
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RESERVED_ALIASES = exports.RESERVED_NAMES = exports.Meta = exports.Command = exports.FlagArg = exports.ListArg = exports.ValueArg = exports.Arg = void 0;
|
|
4
|
+
exports.getArgState = getArgState;
|
|
5
|
+
exports.getCommandState = getCommandState;
|
|
6
|
+
exports.inputDisplayName = inputDisplayName;
|
|
7
|
+
exports.inputSpellings = inputSpellings;
|
|
8
|
+
exports.isMeta = isMeta;
|
|
9
|
+
exports.convertNumber = convertNumber;
|
|
10
|
+
exports.createBuilder = createBuilder;
|
|
11
|
+
const errors_1 = require("./errors");
|
|
12
|
+
const tools_1 = require("./tools");
|
|
13
|
+
const ARG_STATES = new WeakMap();
|
|
14
|
+
const COMMAND_STATES = new WeakMap();
|
|
15
|
+
/**
|
|
16
|
+
* Read the state of a builder-created argument descriptor.
|
|
17
|
+
* Returns `undefined` for other values.
|
|
18
|
+
*/
|
|
19
|
+
function getArgState(value) {
|
|
20
|
+
return typeof value === 'object' && value !== null ? ARG_STATES.get(value) : undefined;
|
|
21
|
+
}
|
|
22
|
+
function getCommandState(value) {
|
|
23
|
+
return typeof value === 'object' && value !== null ? COMMAND_STATES.get(value) : undefined;
|
|
24
|
+
}
|
|
25
|
+
/** Name used in messages and help: the first long name, or the first short alias. */
|
|
26
|
+
function inputDisplayName(input) {
|
|
27
|
+
const [longName] = input.names;
|
|
28
|
+
if (longName !== undefined) {
|
|
29
|
+
return `--${longName}`;
|
|
30
|
+
}
|
|
31
|
+
return `-${input.aliases[0] ?? ''}`;
|
|
32
|
+
}
|
|
33
|
+
/** All input names with their dashes, with short aliases listed first. */
|
|
34
|
+
function inputSpellings(input) {
|
|
35
|
+
return [...input.aliases.map(alias => `-${alias}`), ...input.names.map(name => `--${name}`)];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Descriptor for a value in the parsed result.
|
|
39
|
+
* Create one with `ta.arg()` or `ta.flag()` and include it in the definition callback's result.
|
|
40
|
+
*
|
|
41
|
+
* Descriptors are immutable. Each method returns a new descriptor.
|
|
42
|
+
* For example, the same input can be optional at the top level and required inside a command.
|
|
43
|
+
*/
|
|
44
|
+
class Arg {
|
|
45
|
+
constructor(state) {
|
|
46
|
+
ARG_STATES.set(this, state);
|
|
47
|
+
Object.freeze(this);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.Arg = Arg;
|
|
51
|
+
function stateOf(arg) {
|
|
52
|
+
const state = ARG_STATES.get(arg);
|
|
53
|
+
if (!state) {
|
|
54
|
+
throw new errors_1.DefinitionError('arg descriptor was not created by the talentedArgs builder');
|
|
55
|
+
}
|
|
56
|
+
return state;
|
|
57
|
+
}
|
|
58
|
+
function withInput(arg, patch) {
|
|
59
|
+
const state = stateOf(arg);
|
|
60
|
+
// Changing input settings creates a distinct input. Requirements and defaults can vary while sharing an input.
|
|
61
|
+
return { ...state, input: Object.freeze({ ...state.input, ...patch }) };
|
|
62
|
+
}
|
|
63
|
+
function assertLabel(label) {
|
|
64
|
+
if (typeof label !== 'string' || !label) {
|
|
65
|
+
throw new errors_1.DefinitionError('arg label must be a non-empty string');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** An option that accepts one value, such as `--port 8080`. */
|
|
69
|
+
class ValueArg extends Arg {
|
|
70
|
+
constructor(state) {
|
|
71
|
+
super(state);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Require the user to supply a value for this result property.
|
|
75
|
+
* Removes any previous default.
|
|
76
|
+
*/
|
|
77
|
+
required() {
|
|
78
|
+
return new ValueArg({ ...stateOf(this), presence: 'required', defaultValue: undefined });
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Use `value` at this result property when the user omits the option.
|
|
82
|
+
* Defaults bypass the converter. Replaces any previous requirement.
|
|
83
|
+
*/
|
|
84
|
+
default(value) {
|
|
85
|
+
return new ValueArg({ ...stateOf(this), presence: 'defaulted', defaultValue: value });
|
|
86
|
+
}
|
|
87
|
+
/** Show a custom value label in help, such as `--port TCP_PORT`. */
|
|
88
|
+
label(label) {
|
|
89
|
+
assertLabel(label);
|
|
90
|
+
return new ValueArg(withInput(this, { label }));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Mask the value in the editor, help defaults, command previews, and errors.
|
|
94
|
+
* Your program still receives the value, and clipboard copies include it.
|
|
95
|
+
* Sensitive values are never saved by `remember`.
|
|
96
|
+
*/
|
|
97
|
+
sensitive() {
|
|
98
|
+
return new ValueArg(withInput(this, { sensitive: true }));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Accept a value without its option name, such as `serve 5432` instead of `serve --port 5432`.
|
|
102
|
+
* Only one argument can accept positional values in each active command scope.
|
|
103
|
+
*/
|
|
104
|
+
positional() {
|
|
105
|
+
return new ValueArg(withInput(this, { positional: true }));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Accept multiple values and return an array of converted values.
|
|
109
|
+
* Call this before `required()` or `default()`.
|
|
110
|
+
*/
|
|
111
|
+
multiple(options = {}) {
|
|
112
|
+
const state = stateOf(this);
|
|
113
|
+
if (state.presence !== 'optional') {
|
|
114
|
+
throw new errors_1.DefinitionError(`multiple() on ${inputDisplayName(state.input)} must be called before required() or default()`);
|
|
115
|
+
}
|
|
116
|
+
if (typeof options !== 'object' || options === null) {
|
|
117
|
+
throw new errors_1.DefinitionError(`multiple() options must be given as an object`);
|
|
118
|
+
}
|
|
119
|
+
return new ListArg(withInput(this, { multiple: true, greedy: options.greedy === true }));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.ValueArg = ValueArg;
|
|
123
|
+
/** An option that accepts multiple values, such as `--tag a --tag b`. */
|
|
124
|
+
class ListArg extends Arg {
|
|
125
|
+
constructor(state) {
|
|
126
|
+
super(state);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Require the user to supply at least one value for this result property.
|
|
130
|
+
* Removes any previous default.
|
|
131
|
+
*/
|
|
132
|
+
required() {
|
|
133
|
+
return new ListArg({ ...stateOf(this), presence: 'required', defaultValue: undefined });
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Use `value` at this result property when the user omits the option.
|
|
137
|
+
* Defaults bypass the converter. Replaces any previous requirement.
|
|
138
|
+
*/
|
|
139
|
+
default(value) {
|
|
140
|
+
if (!Array.isArray(value)) {
|
|
141
|
+
throw new errors_1.DefinitionError(`default value of ${inputDisplayName(stateOf(this).input)} must be an array`);
|
|
142
|
+
}
|
|
143
|
+
return new ListArg({ ...stateOf(this), presence: 'defaulted', defaultValue: value });
|
|
144
|
+
}
|
|
145
|
+
/** Show a custom value label in help, such as `--tag NAME`. */
|
|
146
|
+
label(label) {
|
|
147
|
+
assertLabel(label);
|
|
148
|
+
return new ListArg(withInput(this, { label }));
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Mask values in the editor, help defaults, command previews, and errors.
|
|
152
|
+
* Your program still receives the values, and clipboard copies include them.
|
|
153
|
+
* Sensitive values are never saved by `remember`.
|
|
154
|
+
*/
|
|
155
|
+
sensitive() {
|
|
156
|
+
return new ListArg(withInput(this, { sensitive: true }));
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Accept values without the option name, such as `seed users posts`.
|
|
160
|
+
* Only one argument can accept positional values in each active command scope.
|
|
161
|
+
*/
|
|
162
|
+
positional() {
|
|
163
|
+
return new ListArg(withInput(this, { positional: true }));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.ListArg = ListArg;
|
|
167
|
+
/** A boolean flag that takes no value, such as `--verbose`. */
|
|
168
|
+
class FlagArg extends Arg {
|
|
169
|
+
constructor(state) {
|
|
170
|
+
super(state);
|
|
171
|
+
}
|
|
172
|
+
/** Use `value` at this result property when the user omits the flag. */
|
|
173
|
+
default(value) {
|
|
174
|
+
if (typeof value !== 'boolean') {
|
|
175
|
+
throw new errors_1.DefinitionError(`default value of ${inputDisplayName(stateOf(this).input)} must be a boolean`);
|
|
176
|
+
}
|
|
177
|
+
return new FlagArg({ ...stateOf(this), presence: 'defaulted', defaultValue: value });
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Accept `--no-<name>` to set the flag to `false`.
|
|
181
|
+
* Requires a long option name. Applies to each long name unless that negated name
|
|
182
|
+
* already belongs to another option.
|
|
183
|
+
*/
|
|
184
|
+
negatable() {
|
|
185
|
+
const state = stateOf(this);
|
|
186
|
+
if (!state.input.names.length) {
|
|
187
|
+
throw new errors_1.DefinitionError(`${inputDisplayName(state.input)} needs a long name (like --name) to be negatable`);
|
|
188
|
+
}
|
|
189
|
+
return new FlagArg(withInput(this, { negatable: true }));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
exports.FlagArg = FlagArg;
|
|
193
|
+
/**
|
|
194
|
+
* Command descriptor created by `ta.command()`.
|
|
195
|
+
* When selected, its result property contains the command's parsed arguments.
|
|
196
|
+
* The property is absent when another command is selected.
|
|
197
|
+
*/
|
|
198
|
+
class Command {
|
|
199
|
+
constructor(state) {
|
|
200
|
+
COMMAND_STATES.set(this, state);
|
|
201
|
+
Object.freeze(this);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
exports.Command = Command;
|
|
205
|
+
const METAS = new WeakSet();
|
|
206
|
+
/**
|
|
207
|
+
* Descriptor for run metadata in the parsed result.
|
|
208
|
+
* Create one with `ta.meta()` and place it where you want `{ command, interactive }` to appear.
|
|
209
|
+
*/
|
|
210
|
+
class Meta {
|
|
211
|
+
constructor() {
|
|
212
|
+
METAS.add(this);
|
|
213
|
+
Object.freeze(this);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
exports.Meta = Meta;
|
|
217
|
+
function isMeta(value) {
|
|
218
|
+
return typeof value === 'object' && value !== null && METAS.has(value);
|
|
219
|
+
}
|
|
220
|
+
/** Option names reserved for built-in help and interactive mode. */
|
|
221
|
+
exports.RESERVED_NAMES = ['help', 'interactive', 'no-interactive'];
|
|
222
|
+
exports.RESERVED_ALIASES = ['h'];
|
|
223
|
+
const NUMBER_PATTERN = /^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$|^[+-]?0(x[\da-f]+|o[0-7]+|b[01]+)$/i;
|
|
224
|
+
/**
|
|
225
|
+
* Convert numeric text to a finite number.
|
|
226
|
+
* Accepts decimal, exponent, hexadecimal, octal, and binary forms.
|
|
227
|
+
* Rejects empty or whitespace-only strings, `NaN`, and infinity.
|
|
228
|
+
*/
|
|
229
|
+
function convertNumber(value) {
|
|
230
|
+
const trimmed = value.trim();
|
|
231
|
+
const result = NUMBER_PATTERN.test(trimmed) ? Number(trimmed) : NaN;
|
|
232
|
+
if (!Number.isFinite(result)) {
|
|
233
|
+
throw new TypeError(`"${value}" is not a number`);
|
|
234
|
+
}
|
|
235
|
+
return result;
|
|
236
|
+
}
|
|
237
|
+
function convertString(value) {
|
|
238
|
+
return value;
|
|
239
|
+
}
|
|
240
|
+
function parseNames(names) {
|
|
241
|
+
const spellings = Array.isArray(names) ? names : [names];
|
|
242
|
+
if (!spellings.length) {
|
|
243
|
+
throw new errors_1.DefinitionError('arg needs at least one name, like "--port"');
|
|
244
|
+
}
|
|
245
|
+
const longNames = [];
|
|
246
|
+
const aliases = [];
|
|
247
|
+
for (const spelling of spellings) {
|
|
248
|
+
if (typeof spelling !== 'string') {
|
|
249
|
+
throw new errors_1.DefinitionError(`arg names must be strings like "--port" or "-p"`);
|
|
250
|
+
}
|
|
251
|
+
if (/^--[^\s=-][^\s=]*$/.test(spelling)) {
|
|
252
|
+
const name = spelling.slice(2);
|
|
253
|
+
if (exports.RESERVED_NAMES.includes(name)) {
|
|
254
|
+
throw new errors_1.DefinitionError(`"${spelling}" is reserved, pick a different arg name`);
|
|
255
|
+
}
|
|
256
|
+
if (longNames.includes(name)) {
|
|
257
|
+
throw new errors_1.DefinitionError(`arg name "${spelling}" is listed twice`);
|
|
258
|
+
}
|
|
259
|
+
longNames.push(name);
|
|
260
|
+
}
|
|
261
|
+
else if (/^-[^\s=\d-]$/u.test(spelling)) {
|
|
262
|
+
const alias = spelling.slice(1);
|
|
263
|
+
if (exports.RESERVED_ALIASES.includes(alias)) {
|
|
264
|
+
throw new errors_1.DefinitionError(`"${spelling}" is reserved, pick a different arg name`);
|
|
265
|
+
}
|
|
266
|
+
if (aliases.includes(alias)) {
|
|
267
|
+
throw new errors_1.DefinitionError(`arg name "${spelling}" is listed twice`);
|
|
268
|
+
}
|
|
269
|
+
aliases.push(alias);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
throw new errors_1.DefinitionError(`invalid arg name "${spelling}". Use "--name" for long names, or "-n" (single character that isn't a digit) for short ones`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return { names: longNames, aliases };
|
|
276
|
+
}
|
|
277
|
+
function assertDescription(description, target) {
|
|
278
|
+
if (typeof description !== 'string') {
|
|
279
|
+
throw new errors_1.DefinitionError(`description of ${target} must be a string`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function createInput(kind, names, description, convert, valueType) {
|
|
283
|
+
const parsedNames = parseNames(names);
|
|
284
|
+
const input = {
|
|
285
|
+
kind,
|
|
286
|
+
...parsedNames,
|
|
287
|
+
description: '',
|
|
288
|
+
convert,
|
|
289
|
+
valueType,
|
|
290
|
+
label: null,
|
|
291
|
+
multiple: false,
|
|
292
|
+
greedy: false,
|
|
293
|
+
positional: false,
|
|
294
|
+
sensitive: false,
|
|
295
|
+
negatable: false,
|
|
296
|
+
};
|
|
297
|
+
assertDescription(description, inputDisplayName(input));
|
|
298
|
+
return Object.freeze({ ...input, description });
|
|
299
|
+
}
|
|
300
|
+
function arg(names, description, convert) {
|
|
301
|
+
let actualConvert;
|
|
302
|
+
let valueType;
|
|
303
|
+
if (convert === undefined || convert === String) {
|
|
304
|
+
actualConvert = convertString;
|
|
305
|
+
valueType = 'string';
|
|
306
|
+
}
|
|
307
|
+
else if (convert === Number) {
|
|
308
|
+
actualConvert = convertNumber;
|
|
309
|
+
valueType = 'number';
|
|
310
|
+
}
|
|
311
|
+
else if (convert === Boolean) {
|
|
312
|
+
throw new errors_1.DefinitionError(`Boolean can't convert a value from the command line, every text would become true. Use ta.flag() to define a switch`);
|
|
313
|
+
}
|
|
314
|
+
else if (typeof convert === 'function') {
|
|
315
|
+
actualConvert = convert;
|
|
316
|
+
valueType = 'custom';
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
throw new errors_1.DefinitionError(`arg converter must be a function`);
|
|
320
|
+
}
|
|
321
|
+
return new ValueArg({
|
|
322
|
+
input: createInput('value', names, description, actualConvert, valueType),
|
|
323
|
+
presence: 'optional',
|
|
324
|
+
defaultValue: undefined,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
function flag(names, description) {
|
|
328
|
+
return new FlagArg({
|
|
329
|
+
input: createInput('flag', names, description, convertString, 'custom'),
|
|
330
|
+
presence: 'optional',
|
|
331
|
+
defaultValue: undefined,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
function command(token, description, shape = {}) {
|
|
335
|
+
if (typeof token !== 'string' || !/^[^\s=-][^\s=]*$/.test(token)) {
|
|
336
|
+
throw new errors_1.DefinitionError(`invalid command name "${String(token)}". Command names can't be empty, start with a dash, or contain spaces`);
|
|
337
|
+
}
|
|
338
|
+
let summary;
|
|
339
|
+
let details;
|
|
340
|
+
if ((0, tools_1.isPlainObject)(description)) {
|
|
341
|
+
summary = description['summary'];
|
|
342
|
+
details = description['details'] ?? summary;
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
summary = description;
|
|
346
|
+
details = description;
|
|
347
|
+
}
|
|
348
|
+
assertDescription(summary, `command "${token}"`);
|
|
349
|
+
assertDescription(details, `command "${token}"`);
|
|
350
|
+
if (!(0, tools_1.isPlainObject)(shape)) {
|
|
351
|
+
throw new errors_1.DefinitionError(`args of command "${token}" must be given as an object`);
|
|
352
|
+
}
|
|
353
|
+
return new Command({ token, summary, details, shape });
|
|
354
|
+
}
|
|
355
|
+
function meta() {
|
|
356
|
+
return new Meta();
|
|
357
|
+
}
|
|
358
|
+
/** Create the builder passed to the definition callback. */
|
|
359
|
+
function createBuilder() {
|
|
360
|
+
return Object.freeze({ arg, flag, command, meta });
|
|
361
|
+
}
|
|
362
|
+
//# sourceMappingURL=descriptors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptors.js","sourceRoot":"","sources":["../src/descriptors.ts"],"names":[],"mappings":";;;AAmGA,kCAEC;AAED,0CAEC;AAGD,4CAMC;AAGD,wCAEC;AAgPD,wBAEC;AAgND,sCAOC;AAwKD,sCAEC;AA1uBD,qCAA2C;AAC3C,mCAAmD;AA2FnD,MAAM,UAAU,GAAG,IAAI,OAAO,EAAqB,CAAC;AACpD,MAAM,cAAc,GAAG,IAAI,OAAO,EAAyB,CAAC;AAE5D;;;GAGG;AACH,SAAgB,WAAW,CAAC,KAAc;IACxC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACzF,CAAC;AAED,S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InputSpec } from './descriptors';
|
|
3
|
+
import { IUsageIssue } from './errors';
|
|
4
|
+
import { IAppInfo } from './options';
|
|
5
|
+
import { IStyleSpecPainter } from './styling';
|
|
6
|
+
import { ITextTools } from './tools';
|
|
7
|
+
/** Program metadata, schema, styling, and text tools used to render help. */
|
|
8
|
+
export interface IDisplayContext {
|
|
9
|
+
readonly schema: ICompiledSchema;
|
|
10
|
+
readonly appInfo: IAppInfo;
|
|
11
|
+
/** Executable shown in the usage line. */
|
|
12
|
+
readonly executable: string;
|
|
13
|
+
readonly painter: IStyleSpecPainter;
|
|
14
|
+
readonly text: ITextTools;
|
|
15
|
+
/** Available width in terminal columns. */
|
|
16
|
+
readonly width: number;
|
|
17
|
+
}
|
|
18
|
+
/** Fallback help width when terminal dimensions are unavailable. */
|
|
19
|
+
export declare const FALLBACK_WIDTH = 80;
|
|
20
|
+
/** Preferred text column width when the banner includes a logo. */
|
|
21
|
+
export declare const BANNER_TEXT_WIDTH = 40;
|
|
22
|
+
/** Help label for an input's value: its custom label or value type. */
|
|
23
|
+
export declare function inputValueLabel(input: IInputSpec): string;
|
|
24
|
+
/** Format a default value for help. Returns `null` if it has no supported text representation. */
|
|
25
|
+
export declare function formatDefault(value: unknown): string | null;
|
|
26
|
+
/** Help banner with title, description, version, and an optional logo on the right. */
|
|
27
|
+
export declare function renderBanner(context: IDisplayContext): string[];
|
|
28
|
+
/** Render help for the program when `command` is `null`, or for the selected command otherwise. */
|
|
29
|
+
export declare function renderHelp(context: IDisplayContext, command: ICompiledCommand | null): string;
|
|
30
|
+
/** Render usage issues and a help hint. */
|
|
31
|
+
export declare function renderIssues(issues: readonly IUsageIssue[], painter: IStyleSpecPainter, executable: string, command: ICompiledCommand | null): string;
|
package/dist/display.js
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BANNER_TEXT_WIDTH = exports.FALLBACK_WIDTH = void 0;
|
|
4
|
+
exports.inputValueLabel = inputValueLabel;
|
|
5
|
+
exports.formatDefault = formatDefault;
|
|
6
|
+
exports.renderBanner = renderBanner;
|
|
7
|
+
exports.renderHelp = renderHelp;
|
|
8
|
+
exports.renderIssues = renderIssues;
|
|
9
|
+
const compile_1 = require("./compile");
|
|
10
|
+
const descriptors_1 = require("./descriptors");
|
|
11
|
+
const tools_1 = require("./tools");
|
|
12
|
+
/** Fallback help width when terminal dimensions are unavailable. */
|
|
13
|
+
exports.FALLBACK_WIDTH = 80;
|
|
14
|
+
const INDENT = ' ';
|
|
15
|
+
/** Preferred text column width when the banner includes a logo. */
|
|
16
|
+
exports.BANNER_TEXT_WIDTH = 40;
|
|
17
|
+
const BANNER_MIN_TEXT_WIDTH = 28;
|
|
18
|
+
const COLUMN_GAP = 3;
|
|
19
|
+
// *********************************************************************************************************************
|
|
20
|
+
/** Help label for an input's value: its custom label or value type. */
|
|
21
|
+
function inputValueLabel(input) {
|
|
22
|
+
if (input.label !== null) {
|
|
23
|
+
return input.label;
|
|
24
|
+
}
|
|
25
|
+
const base = input.valueType === 'custom' ? 'value' : input.valueType;
|
|
26
|
+
return input.multiple ? `${base}[]` : base;
|
|
27
|
+
}
|
|
28
|
+
/** Format a default value for help. Returns `null` if it has no supported text representation. */
|
|
29
|
+
function formatDefault(value) {
|
|
30
|
+
if (typeof value === 'string') {
|
|
31
|
+
return value === '' ? '""' : value;
|
|
32
|
+
}
|
|
33
|
+
if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {
|
|
34
|
+
return String(value);
|
|
35
|
+
}
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
const items = value.map(formatDefault);
|
|
38
|
+
return items.every((item) => item !== null) ? `[${items.join(', ')}]` : null;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
/** Positional value in the usage line: `<port>` when required, `[port]` when optional. */
|
|
43
|
+
function positionalUsage(input, required) {
|
|
44
|
+
const name = (0, descriptors_1.inputDisplayName)(input).replace(/^-+/, '') + (input.multiple ? '...' : '');
|
|
45
|
+
return required ? `<${name}>` : `[${name}]`;
|
|
46
|
+
}
|
|
47
|
+
function renderRows(rows, context) {
|
|
48
|
+
const { text } = context;
|
|
49
|
+
const available = Math.max(20, context.width - INDENT.length);
|
|
50
|
+
const widestLeft = Math.max(0, ...rows.map(row => text.width(row.left)));
|
|
51
|
+
const leftWidth = Math.min(widestLeft, Math.max(12, Math.floor(available * 0.45)));
|
|
52
|
+
const rightWidth = Math.max(10, available - leftWidth - COLUMN_GAP);
|
|
53
|
+
const rightIndent = ' '.repeat(leftWidth + COLUMN_GAP);
|
|
54
|
+
const lines = [];
|
|
55
|
+
for (const row of rows) {
|
|
56
|
+
const rightLines = row.right ? text.wrap(row.right, rightWidth) : [];
|
|
57
|
+
const leftPadding = ' '.repeat(Math.max(0, leftWidth - text.width(row.left)));
|
|
58
|
+
if (text.width(row.left) > leftWidth) {
|
|
59
|
+
// Place the description below option names that exceed the left column width.
|
|
60
|
+
lines.push(row.leftStyled, ...rightLines.map(line => rightIndent + line));
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const [firstLine, ...otherLines] = rightLines;
|
|
64
|
+
lines.push(firstLine === undefined
|
|
65
|
+
? row.leftStyled
|
|
66
|
+
: row.leftStyled + leftPadding + ' '.repeat(COLUMN_GAP) + firstLine, ...otherLines.map(line => rightIndent + line));
|
|
67
|
+
}
|
|
68
|
+
return lines;
|
|
69
|
+
}
|
|
70
|
+
function inputRow(context, command, input) {
|
|
71
|
+
const { painter } = context;
|
|
72
|
+
const active = (0, compile_1.activeScopeOf)(context.schema, command);
|
|
73
|
+
const negated = (name) => active.negations.get(`no-${name}`) === input;
|
|
74
|
+
const spellings = [
|
|
75
|
+
...input.aliases.map(alias => `-${alias}`),
|
|
76
|
+
...input.names.map(name => (negated(name) ? `--[no-]${name}` : `--${name}`)),
|
|
77
|
+
];
|
|
78
|
+
const label = input.kind === 'value' ? inputValueLabel(input) : '';
|
|
79
|
+
const policy = (0, compile_1.inputPolicy)(context.schema, command, input);
|
|
80
|
+
const notes = [];
|
|
81
|
+
if (input.positional) {
|
|
82
|
+
notes.push(input.multiple ? 'can be given without the option name' : 'can be given as a bare value');
|
|
83
|
+
}
|
|
84
|
+
if (policy.required) {
|
|
85
|
+
notes.push('required');
|
|
86
|
+
}
|
|
87
|
+
const defaultText = policy.hasDefault && !input.sensitive ? formatDefault(policy.defaultValue) : null;
|
|
88
|
+
if (defaultText !== null && input.kind === 'value') {
|
|
89
|
+
notes.push(`default: ${defaultText}`);
|
|
90
|
+
}
|
|
91
|
+
const description = input.description.trim();
|
|
92
|
+
const noteText = notes.length ? `(${notes.join(', ')})` : '';
|
|
93
|
+
return {
|
|
94
|
+
left: spellings.join(', ') + (label ? ` ${label}` : ''),
|
|
95
|
+
leftStyled: spellings.map(painter.option_name).join(', ') +
|
|
96
|
+
(label ? ` ${painter.option_label(label)}` : ''),
|
|
97
|
+
right: [description, noteText].filter(Boolean).join(description.includes('\n') ? '\n' : ' '),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function builtinRows(context) {
|
|
101
|
+
const { painter } = context;
|
|
102
|
+
return [
|
|
103
|
+
{
|
|
104
|
+
left: '-h, --help',
|
|
105
|
+
leftStyled: `${painter.option_name('-h')}, ${painter.option_name('--help')}`,
|
|
106
|
+
right: 'Show help',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
left: '--[no-]interactive',
|
|
110
|
+
leftStyled: painter.option_name('--[no-]interactive'),
|
|
111
|
+
right: 'Open the interactive mode, or never open it',
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
/** Wrap unstyled lines to fit the available width after indentation. */
|
|
116
|
+
function wrapPlain(context, lines) {
|
|
117
|
+
const width = Math.max(20, context.width - INDENT.length);
|
|
118
|
+
return lines.flatMap(line => (line ? context.text.wrap(line, width) : ['']));
|
|
119
|
+
}
|
|
120
|
+
function section(context, title, lines) {
|
|
121
|
+
return [
|
|
122
|
+
context.painter.section_title(title),
|
|
123
|
+
'',
|
|
124
|
+
...lines.map(line => (line ? INDENT + line : line)),
|
|
125
|
+
'',
|
|
126
|
+
];
|
|
127
|
+
}
|
|
128
|
+
// *********************************************************************************************************************
|
|
129
|
+
/** Help banner with title, description, version, and an optional logo on the right. */
|
|
130
|
+
function renderBanner(context) {
|
|
131
|
+
const { appInfo, painter, text, width } = context;
|
|
132
|
+
const { logo } = appInfo;
|
|
133
|
+
const logoWidth = Math.max(0, ...logo.map(line => text.width(line)));
|
|
134
|
+
// Hide the logo if it cannot fit beside the banner text.
|
|
135
|
+
const showLogo = logo.length > 0 && logoWidth <= width;
|
|
136
|
+
const sideBySide = showLogo && width - logoWidth - 1 >= BANNER_MIN_TEXT_WIDTH;
|
|
137
|
+
const textWidth = sideBySide ? Math.min(exports.BANNER_TEXT_WIDTH, width - logoWidth - 1) : width;
|
|
138
|
+
const cell = (raw, paint) => ({
|
|
139
|
+
raw,
|
|
140
|
+
styled: paint(raw),
|
|
141
|
+
});
|
|
142
|
+
const blank = { raw: '', styled: '' };
|
|
143
|
+
// Leave the title unindented and indent the remaining banner lines.
|
|
144
|
+
const cells = [
|
|
145
|
+
blank,
|
|
146
|
+
...text.wrap(appInfo.title, textWidth).map(line => cell(line, painter.banner_title)),
|
|
147
|
+
];
|
|
148
|
+
const bodyWidth = Math.max(10, textWidth - INDENT.length);
|
|
149
|
+
if (appInfo.description) {
|
|
150
|
+
cells.push(blank);
|
|
151
|
+
for (const line of text.wrap(appInfo.description, bodyWidth)) {
|
|
152
|
+
cells.push(line ? { raw: INDENT + line, styled: INDENT + painter.banner_description(line) } : blank);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (appInfo.version) {
|
|
156
|
+
cells.push(blank, {
|
|
157
|
+
raw: INDENT + appInfo.version,
|
|
158
|
+
styled: INDENT + painter.banner_footer(appInfo.version),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (!showLogo) {
|
|
162
|
+
return cells.map(({ styled }) => styled);
|
|
163
|
+
}
|
|
164
|
+
if (!sideBySide) {
|
|
165
|
+
return [...logo.map(painter.banner_logo), ...cells.map(({ styled }) => styled)];
|
|
166
|
+
}
|
|
167
|
+
const lines = [];
|
|
168
|
+
for (let index = 0; index < Math.max(cells.length, logo.length); index++) {
|
|
169
|
+
const { raw, styled } = cells[index] ?? blank;
|
|
170
|
+
const logoLine = logo[index] ?? '';
|
|
171
|
+
lines.push(logoLine
|
|
172
|
+
? styled +
|
|
173
|
+
' '.repeat(Math.max(0, textWidth - text.width(raw)) + 1) +
|
|
174
|
+
painter.banner_logo(logoLine)
|
|
175
|
+
: styled);
|
|
176
|
+
}
|
|
177
|
+
return lines;
|
|
178
|
+
}
|
|
179
|
+
/** Render help for the program when `command` is `null`, or for the selected command otherwise. */
|
|
180
|
+
function renderHelp(context, command) {
|
|
181
|
+
const { schema, painter, text, executable } = context;
|
|
182
|
+
const active = (0, compile_1.activeScopeOf)(schema, command);
|
|
183
|
+
const hasCommands = schema.commands.length > 0;
|
|
184
|
+
const lines = [...renderBanner(context), ''];
|
|
185
|
+
const positional = active.positional
|
|
186
|
+
? ` ${positionalUsage(active.positional, (0, compile_1.inputPolicy)(schema, command, active.positional).required)}`
|
|
187
|
+
: '';
|
|
188
|
+
if (command) {
|
|
189
|
+
lines.push(...section(context, `Command: ${command.token}`, wrapPlain(context, [command.details])), ...section(context, 'Usage', wrapPlain(context, [`$ ${executable} ${command.token} [options]${positional}`])));
|
|
190
|
+
if (active.commandInputs.length) {
|
|
191
|
+
lines.push(...section(context, 'Command options', renderRows(active.commandInputs.map(input => inputRow(context, command, input)), context)));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
else if (hasCommands) {
|
|
195
|
+
const usage = [`$ ${executable} [common options] <command> [command options]`];
|
|
196
|
+
if (schema.rootRunnable) {
|
|
197
|
+
usage.push(`$ ${executable} [common options]${positional}`);
|
|
198
|
+
}
|
|
199
|
+
const commandNameWidth = Math.max(...schema.commands.map(c => text.width(c.token)));
|
|
200
|
+
lines.push(...section(context, 'Usage', wrapPlain(context, usage)), ...section(context, 'Commands', [
|
|
201
|
+
...renderRows(schema.commands.map(({ token, summary }) => ({
|
|
202
|
+
left: (0, tools_1.padEnd)(token, commandNameWidth, text),
|
|
203
|
+
leftStyled: painter.command_name(token) + ' '.repeat(commandNameWidth - text.width(token)),
|
|
204
|
+
right: painter.command_summary(summary),
|
|
205
|
+
})), context),
|
|
206
|
+
'',
|
|
207
|
+
...wrapPlain(context, [
|
|
208
|
+
`Run "${executable} <command> --help" to see the options of a command.`,
|
|
209
|
+
]),
|
|
210
|
+
]));
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
lines.push(...section(context, 'Usage', wrapPlain(context, [`$ ${executable} [options]${positional}`])));
|
|
214
|
+
}
|
|
215
|
+
lines.push(...section(context, hasCommands ? 'Common options' : 'Options', renderRows([
|
|
216
|
+
...active.commonInputs.map(input => inputRow(context, command, input)),
|
|
217
|
+
...builtinRows(context),
|
|
218
|
+
], context)));
|
|
219
|
+
while (lines.length && !lines[lines.length - 1]) {
|
|
220
|
+
lines.pop();
|
|
221
|
+
}
|
|
222
|
+
return lines.join('\n');
|
|
223
|
+
}
|
|
224
|
+
/** Render usage issues and a help hint. */
|
|
225
|
+
function renderIssues(issues, painter, executable, command) {
|
|
226
|
+
return [
|
|
227
|
+
...issues.map(({ message }) => `${painter.error('Error:')} ${message}`),
|
|
228
|
+
'',
|
|
229
|
+
`Run "${[executable, command?.token, '--help']
|
|
230
|
+
.filter(Boolean)
|
|
231
|
+
.join(' ')}" to see how to use it.`,
|
|
232
|
+
'',
|
|
233
|
+
].join('\n');
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=display.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.js","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":";;;AAkCA,0CA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