burgee 0.0.0 → 0.3.0

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.
Files changed (116) hide show
  1. package/README.md +28 -1
  2. package/dist/agent.d.ts +19 -0
  3. package/dist/agent.js +25 -0
  4. package/dist/brand.d.ts +186 -0
  5. package/dist/brand.js +232 -0
  6. package/dist/cli.d.ts +62 -0
  7. package/dist/cli.js +121 -0
  8. package/dist/commander-argument.d.ts +22 -0
  9. package/dist/commander-argument.js +72 -0
  10. package/dist/commander-command.d.ts +355 -0
  11. package/dist/commander-command.js +1621 -0
  12. package/dist/commander-error.d.ts +10 -0
  13. package/dist/commander-error.js +20 -0
  14. package/dist/commander-help.d.ts +67 -0
  15. package/dist/commander-help.js +319 -0
  16. package/dist/commander-option.d.ts +58 -0
  17. package/dist/commander-option.js +164 -0
  18. package/dist/commander-suggest.d.ts +2 -0
  19. package/dist/commander-suggest.js +59 -0
  20. package/dist/commander.d.ts +18 -0
  21. package/dist/commander.js +12 -0
  22. package/dist/completions.d.ts +39 -0
  23. package/dist/completions.js +224 -0
  24. package/dist/config.d.ts +28 -0
  25. package/dist/config.js +98 -0
  26. package/dist/contrast.d.ts +70 -0
  27. package/dist/contrast.js +93 -0
  28. package/dist/dev.d.ts +47 -0
  29. package/dist/dev.js +132 -0
  30. package/dist/execute.d.ts +118 -0
  31. package/dist/execute.js +469 -0
  32. package/dist/exit-code.d.ts +18 -0
  33. package/dist/exit-code.js +12 -0
  34. package/dist/help.d.ts +34 -0
  35. package/dist/help.js +187 -0
  36. package/dist/index.d.ts +16 -1
  37. package/dist/index.js +9 -2
  38. package/dist/manifest.d.ts +207 -0
  39. package/dist/manifest.js +66 -0
  40. package/dist/mcp.d.ts +52 -0
  41. package/dist/mcp.js +124 -0
  42. package/dist/names.d.ts +5 -0
  43. package/dist/names.js +6 -0
  44. package/dist/pkg.d.ts +5 -0
  45. package/dist/pkg.js +21 -0
  46. package/dist/precedence.d.ts +55 -0
  47. package/dist/precedence.js +100 -0
  48. package/dist/runtime.d.ts +39 -0
  49. package/dist/runtime.js +24 -0
  50. package/dist/schema.d.ts +79 -0
  51. package/dist/schema.js +116 -0
  52. package/dist/testing-helpers.d.ts +79 -0
  53. package/dist/testing-helpers.js +145 -0
  54. package/dist/testing.d.ts +10 -0
  55. package/dist/testing.js +3 -0
  56. package/dist/validate.d.ts +27 -0
  57. package/dist/validate.js +133 -0
  58. package/dist/yargs-burgee.d.ts +50 -0
  59. package/dist/yargs-burgee.js +104 -0
  60. package/dist/yargs-cliui.d.ts +56 -0
  61. package/dist/yargs-cliui.js +421 -0
  62. package/dist/yargs-command.d.ts +82 -0
  63. package/dist/yargs-command.js +414 -0
  64. package/dist/yargs-completion.d.ts +41 -0
  65. package/dist/yargs-completion.js +271 -0
  66. package/dist/yargs-factory.d.ts +193 -0
  67. package/dist/yargs-factory.js +1606 -0
  68. package/dist/yargs-helpers.d.ts +6 -0
  69. package/dist/yargs-helpers.js +2 -0
  70. package/dist/yargs-middleware.d.ts +32 -0
  71. package/dist/yargs-middleware.js +81 -0
  72. package/dist/yargs-parser.d.ts +41 -0
  73. package/dist/yargs-parser.js +929 -0
  74. package/dist/yargs-shim.d.ts +54 -0
  75. package/dist/yargs-shim.js +84 -0
  76. package/dist/yargs-usage.d.ts +42 -0
  77. package/dist/yargs-usage.js +479 -0
  78. package/dist/yargs-utils.d.ts +33 -0
  79. package/dist/yargs-utils.js +209 -0
  80. package/dist/yargs-validation.d.ts +26 -0
  81. package/dist/yargs-validation.js +261 -0
  82. package/dist/yargs-y18n.d.ts +21 -0
  83. package/dist/yargs-y18n.js +117 -0
  84. package/dist/yargs.d.ts +6 -0
  85. package/dist/yargs.js +8 -0
  86. package/locales/be.json +46 -0
  87. package/locales/cs.json +51 -0
  88. package/locales/de.json +46 -0
  89. package/locales/en.json +55 -0
  90. package/locales/es.json +46 -0
  91. package/locales/fi.json +49 -0
  92. package/locales/fr.json +53 -0
  93. package/locales/he.json +55 -0
  94. package/locales/hi.json +49 -0
  95. package/locales/hu.json +46 -0
  96. package/locales/id.json +50 -0
  97. package/locales/it.json +46 -0
  98. package/locales/ja.json +51 -0
  99. package/locales/ka.json +55 -0
  100. package/locales/ko.json +49 -0
  101. package/locales/nb.json +44 -0
  102. package/locales/nl.json +49 -0
  103. package/locales/nn.json +44 -0
  104. package/locales/pirate.json +13 -0
  105. package/locales/pl.json +49 -0
  106. package/locales/pt.json +45 -0
  107. package/locales/pt_BR.json +48 -0
  108. package/locales/ru.json +51 -0
  109. package/locales/th.json +46 -0
  110. package/locales/tr.json +48 -0
  111. package/locales/uk_UA.json +51 -0
  112. package/locales/uz.json +52 -0
  113. package/locales/zh_CN.json +48 -0
  114. package/locales/zh_TW.json +51 -0
  115. package/package.json +62 -9
  116. package/dist/index.js.map +0 -1
@@ -0,0 +1,421 @@
1
+ const ANSI_PATTERN = '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))';
2
+ export function stripAnsi(str) {
3
+ return typeof str === 'string' ? str.replace(new RegExp(ANSI_PATTERN, 'g'), '') : str;
4
+ }
5
+ const segmenter = new Intl.Segmenter();
6
+ const EMOJI = new RegExp('^\\p{RGI_Emoji}$', 'v');
7
+ function isWide(code) {
8
+ return ((code >= 0x1100 && code <= 0x115f) ||
9
+ code === 0x2329 ||
10
+ code === 0x232a ||
11
+ (code >= 0x2e80 && code <= 0x303e) ||
12
+ (code >= 0x3041 && code <= 0x33ff) ||
13
+ (code >= 0x3400 && code <= 0x4dbf) ||
14
+ (code >= 0x4e00 && code <= 0x9fff) ||
15
+ (code >= 0xa000 && code <= 0xa4cf) ||
16
+ (code >= 0xa960 && code <= 0xa97f) ||
17
+ (code >= 0xac00 && code <= 0xd7a3) ||
18
+ (code >= 0xf900 && code <= 0xfaff) ||
19
+ (code >= 0xfe10 && code <= 0xfe19) ||
20
+ (code >= 0xfe30 && code <= 0xfe6f) ||
21
+ (code >= 0xff00 && code <= 0xff60) ||
22
+ (code >= 0xffe0 && code <= 0xffe6) ||
23
+ (code >= 0x1f300 && code <= 0x1f64f) ||
24
+ (code >= 0x1f900 && code <= 0x1f9ff) ||
25
+ (code >= 0x20000 && code <= 0x3fffd));
26
+ }
27
+ export function stringWidth(input) {
28
+ if (typeof input !== 'string' || input.length === 0)
29
+ return 0;
30
+ const string = stripAnsi(input);
31
+ if (string.length === 0)
32
+ return 0;
33
+ let width = 0;
34
+ for (const { segment } of segmenter.segment(string)) {
35
+ const code = segment.codePointAt(0);
36
+ if (code <= 0x1f || (code >= 0x7f && code <= 0x9f))
37
+ continue;
38
+ if ((code >= 0x200b && code <= 0x200f) || code === 0xfeff)
39
+ continue;
40
+ if (code >= 0x300 && code <= 0x36f)
41
+ continue;
42
+ if (EMOJI.test(segment)) {
43
+ width += 2;
44
+ continue;
45
+ }
46
+ width += isWide(code) ? 2 : 1;
47
+ }
48
+ return width;
49
+ }
50
+ function closeCode(code) {
51
+ if (code === 1 || code === 2)
52
+ return 22;
53
+ if (code === 3)
54
+ return 23;
55
+ if (code === 4)
56
+ return 24;
57
+ if (code === 7)
58
+ return 27;
59
+ if (code === 8)
60
+ return 28;
61
+ if (code === 9)
62
+ return 29;
63
+ if ((code >= 30 && code <= 37) || (code >= 90 && code <= 97))
64
+ return 39;
65
+ if ((code >= 40 && code <= 47) || (code >= 100 && code <= 107))
66
+ return 49;
67
+ return undefined;
68
+ }
69
+ const ESC = '\u001B';
70
+ const ESCAPES = new Set([ESC, '\u009B']);
71
+ const END_CODE = 39;
72
+ const ANSI_ESCAPE_BELL = '\u0007';
73
+ const ANSI_CSI = '[';
74
+ const ANSI_OSC = ']';
75
+ const ANSI_SGR_TERMINATOR = 'm';
76
+ const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
77
+ const wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
78
+ const wrapAnsiHyperlink = (uri) => `${ESC}${ANSI_ESCAPE_LINK}${uri}${ANSI_ESCAPE_BELL}`;
79
+ const wordLengths = (string) => string.split(' ').map((character) => stringWidth(character));
80
+ function wrapWord(rows, word, columns) {
81
+ const characters = [...word];
82
+ let isInsideEscape = false;
83
+ let isInsideLinkEscape = false;
84
+ let visible = stringWidth(stripAnsi(rows.at(-1)));
85
+ for (const [index, character] of characters.entries()) {
86
+ const characterLength = stringWidth(character);
87
+ if (visible + characterLength <= columns)
88
+ rows[rows.length - 1] += character;
89
+ else {
90
+ rows.push(character);
91
+ visible = 0;
92
+ }
93
+ if (ESCAPES.has(character)) {
94
+ isInsideEscape = true;
95
+ isInsideLinkEscape = characters.slice(index + 1).join('').startsWith(ANSI_ESCAPE_LINK);
96
+ }
97
+ if (isInsideEscape) {
98
+ if (isInsideLinkEscape) {
99
+ if (character === ANSI_ESCAPE_BELL) {
100
+ isInsideEscape = false;
101
+ isInsideLinkEscape = false;
102
+ }
103
+ }
104
+ else if (character === ANSI_SGR_TERMINATOR)
105
+ isInsideEscape = false;
106
+ continue;
107
+ }
108
+ visible += characterLength;
109
+ if (visible === columns && index < characters.length - 1) {
110
+ rows.push('');
111
+ visible = 0;
112
+ }
113
+ }
114
+ if (!visible && rows.at(-1).length > 0 && rows.length > 1)
115
+ rows[rows.length - 2] += rows.pop();
116
+ }
117
+ function stringVisibleTrimSpacesRight(string) {
118
+ const words = string.split(' ');
119
+ let last = words.length;
120
+ while (last > 0) {
121
+ if (stringWidth(words[last - 1]) > 0)
122
+ break;
123
+ last--;
124
+ }
125
+ if (last === words.length)
126
+ return string;
127
+ return words.slice(0, last).join(' ') + words.slice(last).join('');
128
+ }
129
+ function execWrap(string, columns, options = {}) {
130
+ if (options.trim !== false && string.trim() === '')
131
+ return '';
132
+ let returnValue = '';
133
+ let escapeCode;
134
+ let escapeUrl;
135
+ const lengths = wordLengths(string);
136
+ let rows = [''];
137
+ for (const [index, word] of string.split(' ').entries()) {
138
+ if (options.trim !== false)
139
+ rows[rows.length - 1] = rows.at(-1).trimStart();
140
+ let rowLength = stringWidth(rows.at(-1));
141
+ if (index !== 0) {
142
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
143
+ rows.push('');
144
+ rowLength = 0;
145
+ }
146
+ if (rowLength > 0 || options.trim === false) {
147
+ rows[rows.length - 1] += ' ';
148
+ rowLength++;
149
+ }
150
+ }
151
+ const length = lengths[index];
152
+ if (options.hard && length > columns) {
153
+ const remainingColumns = columns - rowLength;
154
+ const breaksStartingThisLine = 1 + Math.floor((length - remainingColumns - 1) / columns);
155
+ const breaksStartingNextLine = Math.floor((length - 1) / columns);
156
+ if (breaksStartingNextLine < breaksStartingThisLine)
157
+ rows.push('');
158
+ wrapWord(rows, word, columns);
159
+ continue;
160
+ }
161
+ if (rowLength + length > columns && rowLength > 0 && length > 0) {
162
+ if (options.wordWrap === false && rowLength < columns) {
163
+ wrapWord(rows, word, columns);
164
+ continue;
165
+ }
166
+ rows.push('');
167
+ }
168
+ if (rowLength + length > columns && options.wordWrap === false) {
169
+ wrapWord(rows, word, columns);
170
+ continue;
171
+ }
172
+ rows[rows.length - 1] += word;
173
+ }
174
+ if (options.trim !== false)
175
+ rows = rows.map(stringVisibleTrimSpacesRight);
176
+ const pre = [...rows.join('\n')];
177
+ for (const [index, character] of pre.entries()) {
178
+ returnValue += character;
179
+ if (ESCAPES.has(character)) {
180
+ const found = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(pre.slice(index).join(''));
181
+ const groups = found?.groups ?? {};
182
+ if (groups.code !== undefined) {
183
+ const code = Number.parseFloat(groups.code);
184
+ escapeCode = code === END_CODE ? undefined : code;
185
+ }
186
+ else if (groups.uri !== undefined)
187
+ escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
188
+ }
189
+ const code = closeCode(Number(escapeCode));
190
+ if (pre[index + 1] === '\n') {
191
+ if (escapeUrl)
192
+ returnValue += wrapAnsiHyperlink('');
193
+ if (escapeCode && code)
194
+ returnValue += wrapAnsiCode(code);
195
+ }
196
+ else if (character === '\n') {
197
+ if (escapeCode && code)
198
+ returnValue += wrapAnsiCode(escapeCode);
199
+ if (escapeUrl)
200
+ returnValue += wrapAnsiHyperlink(escapeUrl);
201
+ }
202
+ }
203
+ return returnValue;
204
+ }
205
+ export function wrapAnsi(string, columns, options) {
206
+ return String(string)
207
+ .normalize()
208
+ .replace(/\r\n/g, '\n')
209
+ .split('\n')
210
+ .map((line) => execWrap(line, columns, options))
211
+ .join('\n');
212
+ }
213
+ const align = { right: alignRight, center: alignCenter };
214
+ const top = 0;
215
+ const right = 1;
216
+ const bottom = 2;
217
+ const left = 3;
218
+ export class UI {
219
+ width;
220
+ wrap;
221
+ rows;
222
+ constructor(opts) {
223
+ this.width = opts.width;
224
+ this.wrap = opts.wrap ?? true;
225
+ this.rows = [];
226
+ }
227
+ span(...args) {
228
+ const cols = this.div(...args);
229
+ cols.span = true;
230
+ }
231
+ resetOutput() {
232
+ this.rows = [];
233
+ }
234
+ div(...args) {
235
+ if (args.length === 0)
236
+ this.div('');
237
+ if (this.wrap && this.shouldApplyLayoutDSL(...args) && typeof args[0] === 'string')
238
+ return this.applyLayoutDSL(args[0]);
239
+ const cols = args.map((arg) => (typeof arg === 'string' ? this.colFromString(arg) : arg));
240
+ this.rows.push(cols);
241
+ return cols;
242
+ }
243
+ shouldApplyLayoutDSL(...args) {
244
+ return args.length === 1 && typeof args[0] === 'string' && /[\t\n]/.test(args[0]);
245
+ }
246
+ applyLayoutDSL(str) {
247
+ const rows = str.split('\n').map((row) => row.split('\t'));
248
+ let leftColumnWidth = 0;
249
+ rows.forEach((columns) => {
250
+ if (columns.length > 1 && stringWidth(columns[0]) > leftColumnWidth) {
251
+ leftColumnWidth = Math.min(Math.floor(this.width * 0.5), stringWidth(columns[0]));
252
+ }
253
+ });
254
+ rows.forEach((columns) => {
255
+ this.div(...columns.map((r, i) => ({
256
+ text: r.trim(),
257
+ padding: this.measurePadding(r),
258
+ width: i === 0 && columns.length > 1 ? leftColumnWidth : undefined,
259
+ })));
260
+ });
261
+ return this.rows[this.rows.length - 1];
262
+ }
263
+ colFromString(text) {
264
+ return { text, padding: this.measurePadding(text) };
265
+ }
266
+ measurePadding(str) {
267
+ const noAnsi = stripAnsi(str);
268
+ return [0, /\s*$/.exec(noAnsi)[0].length, 0, /^\s*/.exec(noAnsi)[0].length];
269
+ }
270
+ toString() {
271
+ const lines = [];
272
+ this.rows.forEach((row) => {
273
+ this.rowToString(row, lines);
274
+ });
275
+ return lines
276
+ .filter((line) => !line.hidden)
277
+ .map((line) => line.text)
278
+ .join('\n');
279
+ }
280
+ rowToString(row, lines) {
281
+ this.rasterize(row).forEach((rrow, r) => {
282
+ let str = '';
283
+ rrow.forEach((col, c) => {
284
+ const column = row[c];
285
+ const { width } = column;
286
+ const wrapWidth = this.negatePadding(column);
287
+ let ts = col;
288
+ if (wrapWidth > stringWidth(col))
289
+ ts += ' '.repeat(wrapWidth - stringWidth(col));
290
+ if (column.align && column.align !== 'left' && this.wrap) {
291
+ const fn = align[column.align];
292
+ ts = fn(ts, wrapWidth);
293
+ if (stringWidth(ts) < wrapWidth)
294
+ ts += ' '.repeat((width || 0) - stringWidth(ts) - 1);
295
+ }
296
+ const padding = column.padding || [0, 0, 0, 0];
297
+ if (padding[left])
298
+ str += ' '.repeat(padding[left]);
299
+ str += addBorder(column, ts, '| ');
300
+ str += ts;
301
+ str += addBorder(column, ts, ' |');
302
+ if (padding[right])
303
+ str += ' '.repeat(padding[right]);
304
+ if (r === 0 && lines.length > 0)
305
+ str = this.renderInline(str, lines.at(-1));
306
+ });
307
+ lines.push({ text: str.replace(/ +$/, ''), span: row.span });
308
+ });
309
+ return lines;
310
+ }
311
+ renderInline(source, previousLine) {
312
+ const match = /^ */.exec(source);
313
+ const leadingWhitespace = match ? match[0].length : 0;
314
+ const target = previousLine.text;
315
+ const targetTextWidth = stringWidth(target.trimEnd());
316
+ if (!previousLine.span)
317
+ return source;
318
+ if (!this.wrap) {
319
+ previousLine.hidden = true;
320
+ return target + source;
321
+ }
322
+ if (leadingWhitespace < targetTextWidth)
323
+ return source;
324
+ previousLine.hidden = true;
325
+ return target.trimEnd() + ' '.repeat(leadingWhitespace - targetTextWidth) + source.trimStart();
326
+ }
327
+ rasterize(row) {
328
+ const rrows = [];
329
+ const widths = this.columnWidths(row);
330
+ let wrapped;
331
+ row.forEach((col, c) => {
332
+ col.width = widths[c];
333
+ if (this.wrap)
334
+ wrapped = wrapAnsi(col.text, this.negatePadding(col), { hard: true }).split('\n');
335
+ else
336
+ wrapped = col.text.split('\n');
337
+ if (col.border) {
338
+ wrapped.unshift(`.${'-'.repeat(this.negatePadding(col) + 2)}.`);
339
+ wrapped.push(`'${'-'.repeat(this.negatePadding(col) + 2)}'`);
340
+ }
341
+ if (col.padding) {
342
+ wrapped.unshift(...new Array(col.padding[top] || 0).fill(''));
343
+ wrapped.push(...new Array(col.padding[bottom] || 0).fill(''));
344
+ }
345
+ wrapped.forEach((str, r) => {
346
+ if (!rrows[r])
347
+ rrows.push([]);
348
+ const rrow = rrows[r];
349
+ for (let i = 0; i < c; i++) {
350
+ if (rrow[i] === undefined)
351
+ rrow.push('');
352
+ }
353
+ rrow.push(str);
354
+ });
355
+ });
356
+ return rrows;
357
+ }
358
+ negatePadding(col) {
359
+ let wrapWidth = col.width || 0;
360
+ if (col.padding)
361
+ wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
362
+ if (col.border)
363
+ wrapWidth -= 4;
364
+ return wrapWidth;
365
+ }
366
+ columnWidths(row) {
367
+ if (!this.wrap)
368
+ return row.map((col) => col.width || stringWidth(col.text));
369
+ let unset = row.length;
370
+ let remainingWidth = this.width;
371
+ const widths = row.map((col) => {
372
+ if (col.width) {
373
+ unset--;
374
+ remainingWidth -= col.width;
375
+ return col.width;
376
+ }
377
+ return undefined;
378
+ });
379
+ const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
380
+ return widths.map((w, i) => (w === undefined ? Math.max(unsetWidth, minWidth(row[i])) : w));
381
+ }
382
+ }
383
+ function addBorder(col, ts, style) {
384
+ if (col.border) {
385
+ if (/[.']-+[.']/.test(ts))
386
+ return '';
387
+ if (ts.trim().length !== 0)
388
+ return style;
389
+ return ' ';
390
+ }
391
+ return '';
392
+ }
393
+ function minWidth(col) {
394
+ const padding = col.padding || [];
395
+ const min = 1 + (padding[left] || 0) + (padding[right] || 0);
396
+ if (col.border)
397
+ return min + 4;
398
+ return min;
399
+ }
400
+ function getWindowWidth() {
401
+ if (typeof process === 'object' && process.stdout && process.stdout.columns)
402
+ return process.stdout.columns;
403
+ return 80;
404
+ }
405
+ function alignRight(str, width) {
406
+ str = str.trim();
407
+ const strWidth = stringWidth(str);
408
+ if (strWidth < width)
409
+ return ' '.repeat(width - strWidth) + str;
410
+ return str;
411
+ }
412
+ function alignCenter(str, width) {
413
+ str = str.trim();
414
+ const strWidth = stringWidth(str);
415
+ if (strWidth >= width)
416
+ return str;
417
+ return ' '.repeat((width - strWidth) >> 1) + str;
418
+ }
419
+ export function cliui(opts) {
420
+ return new UI({ width: opts?.width || getWindowWidth(), wrap: opts?.wrap });
421
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * yargs' command instance — `.command()` in its five shapes, `.commandDir()`, the
3
+ * builder/handler pipeline, positionals and the default command — ported for
4
+ * `burgee/yargs`.
5
+ */
6
+ import { type Middleware } from './yargs-middleware.js';
7
+ import type { PlatformShim } from './yargs-shim.js';
8
+ import type { UsageInstance } from './yargs-usage.js';
9
+ import { type Positional } from './yargs-utils.js';
10
+ import type { ValidationInstance } from './yargs-validation.js';
11
+ export interface CommandHandler {
12
+ original: string;
13
+ description?: string | false | undefined;
14
+ handler: (argv: any) => any;
15
+ builder: any;
16
+ middlewares: Middleware[];
17
+ deprecated?: boolean | string | undefined;
18
+ demanded: Positional[];
19
+ optional: Positional[];
20
+ }
21
+ export interface CommandHandlerDefinition {
22
+ command?: string | string[];
23
+ aliases?: string[];
24
+ describe?: string | false;
25
+ description?: string | false;
26
+ desc?: string | false;
27
+ builder?: any;
28
+ handler?: (argv: any) => any;
29
+ middlewares?: Middleware[];
30
+ deprecated?: boolean | string;
31
+ }
32
+ export interface CommandBuilderDefinition {
33
+ builder: any;
34
+ handler: (argv: any) => any;
35
+ middlewares?: Middleware[];
36
+ deprecated?: boolean | string;
37
+ }
38
+ export declare function isYargsInstance(y: any): boolean;
39
+ export declare class CommandInstance {
40
+ private requireCache;
41
+ private handlers;
42
+ private aliasMap;
43
+ private defaultCommand;
44
+ private frozens;
45
+ private readonly shim;
46
+ private readonly usage;
47
+ private readonly globalMiddleware;
48
+ private readonly validation;
49
+ constructor(usage: UsageInstance, validation: ValidationInstance, globalMiddleware: any, shim: PlatformShim);
50
+ addDirectory(dir: string, req: (p: string) => any, callerFile: string, opts?: any): void;
51
+ addHandler(cmd: string | string[] | CommandHandlerDefinition, description?: string | false, builder?: any, handler?: (argv: any) => any, commandMiddleware?: Middleware[], deprecated?: boolean | string): void;
52
+ getCommandHandlers(): Record<string, CommandHandler>;
53
+ getCommands(): string[];
54
+ hasDefaultCommand(): boolean;
55
+ runCommand(command: string | null, yargs: any, parsed: any, commandIndex: number, helpOnly: boolean, helpOrVersionSet: boolean): any;
56
+ private applyBuilderUpdateUsageAndParse;
57
+ private parseAndUpdateUsage;
58
+ private shouldUpdateUsage;
59
+ private usageFromParentCommandsCommandHandler;
60
+ private handleValidationAndGetResult;
61
+ private applyMiddlewareAndGetResult;
62
+ private populatePositionals;
63
+ private populatePositional;
64
+ cmdToParseOptions(cmdString: string): {
65
+ array: string[];
66
+ default: Record<string, any>;
67
+ alias: Record<string, string[]>;
68
+ demand: Record<string, boolean>;
69
+ };
70
+ private postProcessPositionals;
71
+ private isDefaulted;
72
+ private isInConfigs;
73
+ runDefaultBuilderOn(yargs: any): any;
74
+ private extractDesc;
75
+ freeze(): void;
76
+ unfreeze(): void;
77
+ reset(): CommandInstance;
78
+ }
79
+ export declare function command(usage: UsageInstance, validation: ValidationInstance, globalMiddleware: any, shim: PlatformShim): CommandInstance;
80
+ export declare function isCommandBuilderDefinition(builder: any): builder is CommandBuilderDefinition;
81
+ export declare function isCommandBuilderCallback(builder: any): builder is (yargs: any, helpOrVersionSet: boolean) => any;
82
+ export declare function isCommandHandlerDefinition(cmd: any): cmd is CommandHandlerDefinition;