massarg 1.0.7-pre.1 → 2.0.0-pre.2
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 +126 -209
- package/command.d.ts +157 -0
- package/command.d.ts.map +1 -0
- package/command.js +319 -0
- package/command.js.map +1 -0
- package/error.d.ts +36 -0
- package/error.d.ts.map +1 -0
- package/error.js +37 -0
- package/error.js.map +1 -0
- package/example.d.ts +31 -0
- package/example.d.ts.map +1 -0
- package/example.js +41 -0
- package/example.js.map +1 -0
- package/help.d.ts +729 -0
- package/help.d.ts.map +1 -0
- package/help.js +253 -0
- package/help.js.map +1 -0
- package/index.d.ts +1 -70
- package/index.d.ts.map +1 -1
- package/index.js +13 -688
- package/index.js.map +1 -1
- package/massarg.d.ts +8 -0
- package/massarg.d.ts.map +1 -0
- package/massarg.js +23 -0
- package/massarg.js.map +1 -0
- package/option.d.ts +244 -0
- package/option.d.ts.map +1 -0
- package/option.js +308 -0
- package/option.js.map +1 -0
- package/package.json +22 -15
- package/style.d.ts +45 -0
- package/style.d.ts.map +1 -0
- package/style.js +52 -0
- package/style.js.map +1 -0
- package/utils.d.ts +33 -13
- package/utils.d.ts.map +1 -1
- package/utils.js +97 -110
- package/utils.js.map +1 -1
- package/assertions.d.ts +0 -8
- package/assertions.d.ts.map +0 -1
- package/assertions.js +0 -145
- package/assertions.js.map +0 -1
- package/errors.d.ts +0 -7
- package/errors.d.ts.map +0 -1
- package/errors.js +0 -33
- package/errors.js.map +0 -1
- package/types.d.ts +0 -224
- package/types.d.ts.map +0 -1
- package/types.js +0 -3
- package/types.js.map +0 -1
package/help.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAEnB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,YA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE7D,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAA;AAEnD,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,UAAU,CAyDtD,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,qBAAa,aAAa;IACxB,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,CAAA;IAC1B,MAAM,EAAE,YAAY,CAAC,UAAU,CAAC,CAAA;gBAEpB,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,EAAE,UAAU;IAe3D,QAAQ,IAAI,MAAM;IA8ElB,SAAS,IAAI,IAAI;CAGlB"}
|
package/help.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HelpGenerator = exports.defaultHelpConfig = exports.HelpConfig = exports.GenerateTableOptionConfig = exports.GenerateTableCommandConfig = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const style_1 = require("./style");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
|
+
exports.GenerateTableCommandConfig = zod_1.default.object({
|
|
11
|
+
maxRowLength: zod_1.default.number().optional(),
|
|
12
|
+
namePrefix: zod_1.default.string().optional(),
|
|
13
|
+
aliasPrefix: zod_1.default.string().optional(),
|
|
14
|
+
compact: zod_1.default.boolean().optional(),
|
|
15
|
+
nameStyle: style_1.StringStyle.optional(),
|
|
16
|
+
descriptionStyle: style_1.StringStyle.optional(),
|
|
17
|
+
});
|
|
18
|
+
exports.GenerateTableOptionConfig = exports.GenerateTableCommandConfig;
|
|
19
|
+
exports.HelpConfig = zod_1.default.object({
|
|
20
|
+
/**
|
|
21
|
+
* Whether to bind the help command to this command
|
|
22
|
+
*
|
|
23
|
+
* Set this to `true` to automatically add a `help` command to this command's subcommands.
|
|
24
|
+
*/
|
|
25
|
+
bindCommand: zod_1.default.boolean().optional(),
|
|
26
|
+
/**
|
|
27
|
+
* Whether to bind the help option to this command
|
|
28
|
+
*
|
|
29
|
+
* Set this to `true` to automatically add a `--help` option to this command's options.
|
|
30
|
+
*/
|
|
31
|
+
bindOption: zod_1.default.boolean().optional(),
|
|
32
|
+
/** Options for generating the table of commands */
|
|
33
|
+
commandOptions: exports.GenerateTableCommandConfig.omit({ maxRowLength: true }).optional(),
|
|
34
|
+
/** Options for generating the table of options */
|
|
35
|
+
optionOptions: exports.GenerateTableOptionConfig.omit({ maxRowLength: true }).optional(),
|
|
36
|
+
/** Style of the help title */
|
|
37
|
+
titleStyle: style_1.StringStyle.optional(),
|
|
38
|
+
/** Style of the help description */
|
|
39
|
+
descriptionStyle: style_1.StringStyle.optional(),
|
|
40
|
+
/** Style of the help subtitles for commands, options and examples */
|
|
41
|
+
subtitleStyle: style_1.StringStyle.optional(),
|
|
42
|
+
/** Style of the help usage */
|
|
43
|
+
usageStyle: style_1.StringStyle.optional(),
|
|
44
|
+
/** Style of the help header */
|
|
45
|
+
headerStyle: style_1.StringStyle.optional(),
|
|
46
|
+
/** Style of the help footer */
|
|
47
|
+
footerStyle: style_1.StringStyle.optional(),
|
|
48
|
+
/** Maximum length of a row in the help output */
|
|
49
|
+
maxRowLength: zod_1.default.number().optional(),
|
|
50
|
+
/** Options for examples section */
|
|
51
|
+
exampleOptions: zod_1.default
|
|
52
|
+
.object({
|
|
53
|
+
/** Style of the example description */
|
|
54
|
+
descriptionStyle: style_1.StringStyle.optional(),
|
|
55
|
+
/** Style of the example input */
|
|
56
|
+
inputStyle: style_1.StringStyle.optional(),
|
|
57
|
+
/** Style of the example output */
|
|
58
|
+
outputStyle: style_1.StringStyle.optional(),
|
|
59
|
+
/** Prefix for the example input */
|
|
60
|
+
inputPrefix: zod_1.default.string().default('$').optional(),
|
|
61
|
+
/** Prefix for the example output */
|
|
62
|
+
outputPrefix: zod_1.default.string().default('>').optional(),
|
|
63
|
+
})
|
|
64
|
+
.optional(),
|
|
65
|
+
/** Text to display at the very top, describing CLI usage */
|
|
66
|
+
usageText: zod_1.default.string().optional(),
|
|
67
|
+
/** Text to display above the description, below the usage */
|
|
68
|
+
headerText: zod_1.default.string().optional(),
|
|
69
|
+
/** Text to display at the very bottom, below the examples */
|
|
70
|
+
footerText: zod_1.default.string().optional(),
|
|
71
|
+
});
|
|
72
|
+
exports.defaultHelpConfig = {
|
|
73
|
+
maxRowLength: 80,
|
|
74
|
+
commandOptions: {
|
|
75
|
+
namePrefix: '',
|
|
76
|
+
aliasPrefix: '',
|
|
77
|
+
nameStyle: {
|
|
78
|
+
color: 'yellow',
|
|
79
|
+
},
|
|
80
|
+
descriptionStyle: {
|
|
81
|
+
color: 'gray',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
optionOptions: {
|
|
85
|
+
namePrefix: '--',
|
|
86
|
+
aliasPrefix: '-',
|
|
87
|
+
nameStyle: {
|
|
88
|
+
color: 'yellow',
|
|
89
|
+
},
|
|
90
|
+
descriptionStyle: {
|
|
91
|
+
color: 'gray',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
descriptionStyle: {},
|
|
95
|
+
exampleOptions: {
|
|
96
|
+
descriptionStyle: {
|
|
97
|
+
bold: true,
|
|
98
|
+
color: 'brightWhite',
|
|
99
|
+
},
|
|
100
|
+
inputStyle: {
|
|
101
|
+
color: 'yellow',
|
|
102
|
+
},
|
|
103
|
+
outputStyle: {
|
|
104
|
+
color: 'brightWhite',
|
|
105
|
+
},
|
|
106
|
+
inputPrefix: '$',
|
|
107
|
+
outputPrefix: '>',
|
|
108
|
+
},
|
|
109
|
+
bindCommand: false,
|
|
110
|
+
bindOption: false,
|
|
111
|
+
titleStyle: {
|
|
112
|
+
bold: true,
|
|
113
|
+
color: 'yellow',
|
|
114
|
+
},
|
|
115
|
+
usageStyle: {
|
|
116
|
+
bold: true,
|
|
117
|
+
color: 'yellow',
|
|
118
|
+
},
|
|
119
|
+
subtitleStyle: {
|
|
120
|
+
bold: true,
|
|
121
|
+
color: 'brightWhite',
|
|
122
|
+
underline: true,
|
|
123
|
+
},
|
|
124
|
+
headerText: '',
|
|
125
|
+
footerText: '',
|
|
126
|
+
usageText: '',
|
|
127
|
+
headerStyle: {},
|
|
128
|
+
footerStyle: {},
|
|
129
|
+
};
|
|
130
|
+
class HelpGenerator {
|
|
131
|
+
constructor(entry, config) {
|
|
132
|
+
this.entry = entry;
|
|
133
|
+
this.config = exports.HelpConfig.required().parse({
|
|
134
|
+
...entry.helpConfig,
|
|
135
|
+
commandOptions: {
|
|
136
|
+
...entry.helpConfig?.commandOptions,
|
|
137
|
+
...config?.commandOptions,
|
|
138
|
+
},
|
|
139
|
+
optionOptions: {
|
|
140
|
+
...entry.helpConfig?.optionOptions,
|
|
141
|
+
...config?.optionOptions,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
generate() {
|
|
146
|
+
const entry = this.entry;
|
|
147
|
+
const CMD_OPT_INDENT = 4;
|
|
148
|
+
const _wrap = (text, indent = 0) => wrap(text, this.config.maxRowLength - indent);
|
|
149
|
+
const options = generateHelpTable(entry.options, {
|
|
150
|
+
...this.config.optionOptions,
|
|
151
|
+
maxRowLength: this.config.maxRowLength - CMD_OPT_INDENT,
|
|
152
|
+
}).trimEnd();
|
|
153
|
+
const commands = generateHelpTable(entry.commands, {
|
|
154
|
+
...this.config.commandOptions,
|
|
155
|
+
maxRowLength: this.config.maxRowLength - CMD_OPT_INDENT,
|
|
156
|
+
}).trimEnd();
|
|
157
|
+
const examples = entry.examples
|
|
158
|
+
.map((example) => {
|
|
159
|
+
const { description, input, output } = example;
|
|
160
|
+
return (0, utils_1.strConcat)(description && [
|
|
161
|
+
_wrap((0, style_1.format)(description, this.config.exampleOptions.descriptionStyle), 4),
|
|
162
|
+
'',
|
|
163
|
+
], input &&
|
|
164
|
+
_wrap((0, style_1.format)([this.config.exampleOptions.inputPrefix, input].filter(Boolean).join(' '), this.config.exampleOptions.inputStyle), 4), output &&
|
|
165
|
+
_wrap((0, style_1.format)([this.config.exampleOptions.outputPrefix, output].filter(Boolean).join(' '), this.config.exampleOptions.outputStyle), 4));
|
|
166
|
+
})
|
|
167
|
+
.join('\n');
|
|
168
|
+
const { headerText, footerText, usageText } = this.config;
|
|
169
|
+
return ((0, utils_1.strConcat)(_wrap((0, style_1.format)(usageText ||
|
|
170
|
+
[`Usage:`, entry.name, commands.length && '[command]', options.length && '[options]']
|
|
171
|
+
.filter(Boolean)
|
|
172
|
+
.join(' '), this.config.usageStyle)), headerText.length && ['', (0, style_1.format)(headerText, this.config.descriptionStyle)], entry.description.length && [
|
|
173
|
+
'',
|
|
174
|
+
_wrap((0, style_1.format)(entry.description, this.config.descriptionStyle)),
|
|
175
|
+
], commands.length &&
|
|
176
|
+
(0, utils_1.indent)([
|
|
177
|
+
'',
|
|
178
|
+
(0, style_1.format)(`Commands for ${entry.name}:`, this.config.subtitleStyle),
|
|
179
|
+
'',
|
|
180
|
+
(0, utils_1.indent)(commands),
|
|
181
|
+
]), options.length &&
|
|
182
|
+
(0, utils_1.indent)([
|
|
183
|
+
'',
|
|
184
|
+
(0, style_1.format)(`Options for ${entry.name}:`, this.config.subtitleStyle),
|
|
185
|
+
'',
|
|
186
|
+
(0, utils_1.indent)(options),
|
|
187
|
+
]), examples.length &&
|
|
188
|
+
(0, utils_1.indent)(['', (0, style_1.format)('Examples:', this.config.subtitleStyle), '', (0, utils_1.indent)(examples)]), footerText.length && ['', _wrap((0, style_1.format)(footerText, this.config.descriptionStyle))]) + '\n');
|
|
189
|
+
}
|
|
190
|
+
printHelp() {
|
|
191
|
+
console.log(this.generate());
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
exports.HelpGenerator = HelpGenerator;
|
|
195
|
+
function wrap(text, maxRowLength) {
|
|
196
|
+
const length = (0, style_1.stripStyle)(text).length;
|
|
197
|
+
if (length <= maxRowLength) {
|
|
198
|
+
return text;
|
|
199
|
+
}
|
|
200
|
+
const subRows = [];
|
|
201
|
+
const words = text.split(' ');
|
|
202
|
+
let currentRow = '';
|
|
203
|
+
for (const word of words) {
|
|
204
|
+
if ((0, style_1.stripStyle)(currentRow).length + (0, style_1.stripStyle)(word).length + 1 > maxRowLength) {
|
|
205
|
+
subRows.push(currentRow);
|
|
206
|
+
currentRow = '';
|
|
207
|
+
}
|
|
208
|
+
currentRow += `${word} `;
|
|
209
|
+
}
|
|
210
|
+
subRows.push(currentRow);
|
|
211
|
+
return subRows.join('\n');
|
|
212
|
+
}
|
|
213
|
+
function generateHelpTable(items, { maxRowLength = 80, namePrefix = '', aliasPrefix = '', compact = false, ...config } = {}) {
|
|
214
|
+
const rows = items
|
|
215
|
+
.map((o) => {
|
|
216
|
+
const name = `${namePrefix}${o.name}${o.aliases.length ? ` | ${aliasPrefix}${o.aliases.join(`|${aliasPrefix}`)}` : ''}`;
|
|
217
|
+
const description = o.description;
|
|
218
|
+
const hidden = o.hidden || false;
|
|
219
|
+
return { name, description, hidden };
|
|
220
|
+
})
|
|
221
|
+
.filter((r) => !r.hidden);
|
|
222
|
+
const maxNameLength = Math.max(...rows.map((o) => o.name.length));
|
|
223
|
+
const nameStyle = (name) => (0, style_1.format)(name, config.nameStyle);
|
|
224
|
+
const descStyle = (desc) => (0, style_1.format)(desc, config.descriptionStyle);
|
|
225
|
+
const table = rows.map((row) => {
|
|
226
|
+
const name = nameStyle(row.name.padEnd(maxNameLength + 2));
|
|
227
|
+
const description = descStyle(row.description);
|
|
228
|
+
const length = (0, style_1.stripStyle)(name).length + (0, style_1.stripStyle)(description).length;
|
|
229
|
+
if (length <= maxRowLength) {
|
|
230
|
+
const line = `${name}${description}`;
|
|
231
|
+
if (!compact) {
|
|
232
|
+
return `${line}\n`;
|
|
233
|
+
}
|
|
234
|
+
return line;
|
|
235
|
+
}
|
|
236
|
+
const subRows = [];
|
|
237
|
+
const words = description.split(' ');
|
|
238
|
+
let currentRow = name;
|
|
239
|
+
for (const word of words) {
|
|
240
|
+
if ((0, style_1.stripStyle)(currentRow).length + (0, style_1.stripStyle)(word).length + 1 > maxRowLength) {
|
|
241
|
+
subRows.push(currentRow);
|
|
242
|
+
currentRow = ' '.repeat(maxNameLength + 2);
|
|
243
|
+
}
|
|
244
|
+
currentRow += `${word} `;
|
|
245
|
+
}
|
|
246
|
+
if (!compact) {
|
|
247
|
+
subRows.push('');
|
|
248
|
+
}
|
|
249
|
+
return subRows.join('\n');
|
|
250
|
+
});
|
|
251
|
+
return table.join('\n');
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=help.js.map
|
package/help.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAmB;AACnB,mCAAyD;AAEzD,mCAAyD;AAE5C,QAAA,0BAA0B,GAAG,aAAC,CAAC,MAAM,CAAC;IACjD,YAAY,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,UAAU,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,WAAW,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,OAAO,EAAE,aAAC,CAAC,OAAO,EAAE,CA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,MAAM,IAAI,YAAY,EAAE;YAC1B,MAAM,IAAI,GAAG,GAAG,IAAI,GAAG,WAAW,EAAE,CAAA;YACpC,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,GAAG,IAAI,IAAI,CAAA;aACnB;YACD,OAAO,IAAI,CAAA;SACZ;QACD,MAAM,OAAO,GAAa,EAAE,CAAA;QAC5B,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACpC,IAAI,UAAU,GAAG,IAAI,CAAA;QAErB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,IAAI,IAAA,kBAAU,EAAC,UAAU,CAAC,CAAC,MAAM,GAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,YAAY,EAAE;gBAC9E,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;gBACxB,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,CAAA;aAC3C;YACD,UAAU,IAAI,GAAG,IAAI,GAAG,CAAA;SACzB;QAED,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;SACjB;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
|
package/index.d.ts
CHANGED
|
@@ -1,71 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { OptionsBase, CommandDef, HelpDef, MainDef, OptionDef, ExampleDef } from "./types";
|
|
3
|
-
export declare class Massarg<Options> {
|
|
4
|
-
private _main?;
|
|
5
|
-
private _options;
|
|
6
|
-
private _commands;
|
|
7
|
-
private _runCommand?;
|
|
8
|
-
private _examples;
|
|
9
|
-
private _maxNameLen;
|
|
10
|
-
/**
|
|
11
|
-
* These are the parsed options passed via args. They will only be available after using `parse()` or `printHelp()`,
|
|
12
|
-
* or when returned by `parseArgs()`. */
|
|
13
|
-
data: Options & OptionsBase;
|
|
14
|
-
private _help;
|
|
15
|
-
private _requiredOptions;
|
|
16
|
-
constructor();
|
|
17
|
-
/** Define the main command to run when no commands are passed. */
|
|
18
|
-
main(run: MainDef<Options>): Massarg<Options>;
|
|
19
|
-
/** Add option to be parsed */
|
|
20
|
-
option<Value>(option: OptionDef<Options, Value>): Massarg<Options>;
|
|
21
|
-
/** Add example line to be added to the help text. */
|
|
22
|
-
example(example: ExampleDef): Massarg<Options>;
|
|
23
|
-
/** Add command to be run */
|
|
24
|
-
command(command: CommandDef<Options>): Massarg<Options>;
|
|
25
|
-
/** Set options for behavior of the help text print. */
|
|
26
|
-
help(help: HelpDef): Massarg<Options>;
|
|
27
|
-
/**
|
|
28
|
-
* Print the help text without being required to pass option.
|
|
29
|
-
*
|
|
30
|
-
* @param args If args weren't already parsed, you can add them here
|
|
31
|
-
*/
|
|
32
|
-
printHelp(args?: string[]): void;
|
|
33
|
-
/**
|
|
34
|
-
* Get the help text as an array of lines. Useful for manipulating the response or querying before displaying
|
|
35
|
-
* to the user.
|
|
36
|
-
*/
|
|
37
|
-
getHelpString(args?: string[]): string[];
|
|
38
|
-
/**
|
|
39
|
-
* Parse the arguments without running the commands related to them. Useful for testing or querying the data from the
|
|
40
|
-
* args manually, if it is for some reason not enough to parse it normally through defining commands.
|
|
41
|
-
* @param args Arguments to parse. Defaults to `process.argv`
|
|
42
|
-
* @returns Parsed options
|
|
43
|
-
*/
|
|
44
|
-
parseArgs(args?: string[]): Options & OptionsBase;
|
|
45
|
-
/**
|
|
46
|
-
* Parse the given args, running any relevant commands in the process.
|
|
47
|
-
*
|
|
48
|
-
* @param args args to parse. Defaults to `process.argv`
|
|
49
|
-
*/
|
|
50
|
-
parse(args?: string[]): void;
|
|
51
|
-
private _prepareRequired;
|
|
52
|
-
private _printExamples;
|
|
53
|
-
private _isTruthy;
|
|
54
|
-
private _ensureRequired;
|
|
55
|
-
private _addOptionToData;
|
|
56
|
-
private _pushToArrayData;
|
|
57
|
-
private _getWrappedLines;
|
|
58
|
-
private _printCommands;
|
|
59
|
-
private _printOptions;
|
|
60
|
-
private _optionDescription;
|
|
61
|
-
private _fullCmdName;
|
|
62
|
-
private _fullOptName;
|
|
63
|
-
private _commandOptions;
|
|
64
|
-
private _optionCommands;
|
|
65
|
-
private _globalOptions;
|
|
66
|
-
private color;
|
|
67
|
-
private colorCount;
|
|
68
|
-
}
|
|
69
|
-
export declare function massarg<T>(): Massarg<T>;
|
|
70
|
-
export default massarg;
|
|
1
|
+
export * from './massarg';
|
|
71
2
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|