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.
- package/README.md +28 -1
- package/dist/agent.d.ts +19 -0
- package/dist/agent.js +25 -0
- package/dist/brand.d.ts +186 -0
- package/dist/brand.js +232 -0
- package/dist/cli.d.ts +62 -0
- package/dist/cli.js +121 -0
- package/dist/commander-argument.d.ts +22 -0
- package/dist/commander-argument.js +72 -0
- package/dist/commander-command.d.ts +355 -0
- package/dist/commander-command.js +1621 -0
- package/dist/commander-error.d.ts +10 -0
- package/dist/commander-error.js +20 -0
- package/dist/commander-help.d.ts +67 -0
- package/dist/commander-help.js +319 -0
- package/dist/commander-option.d.ts +58 -0
- package/dist/commander-option.js +164 -0
- package/dist/commander-suggest.d.ts +2 -0
- package/dist/commander-suggest.js +59 -0
- package/dist/commander.d.ts +18 -0
- package/dist/commander.js +12 -0
- package/dist/completions.d.ts +39 -0
- package/dist/completions.js +224 -0
- package/dist/config.d.ts +28 -0
- package/dist/config.js +98 -0
- package/dist/contrast.d.ts +70 -0
- package/dist/contrast.js +93 -0
- package/dist/dev.d.ts +47 -0
- package/dist/dev.js +132 -0
- package/dist/execute.d.ts +118 -0
- package/dist/execute.js +469 -0
- package/dist/exit-code.d.ts +18 -0
- package/dist/exit-code.js +12 -0
- package/dist/help.d.ts +34 -0
- package/dist/help.js +187 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.js +9 -2
- package/dist/manifest.d.ts +207 -0
- package/dist/manifest.js +66 -0
- package/dist/mcp.d.ts +52 -0
- package/dist/mcp.js +124 -0
- package/dist/names.d.ts +5 -0
- package/dist/names.js +6 -0
- package/dist/pkg.d.ts +5 -0
- package/dist/pkg.js +21 -0
- package/dist/precedence.d.ts +55 -0
- package/dist/precedence.js +100 -0
- package/dist/runtime.d.ts +39 -0
- package/dist/runtime.js +24 -0
- package/dist/schema.d.ts +79 -0
- package/dist/schema.js +116 -0
- package/dist/testing-helpers.d.ts +79 -0
- package/dist/testing-helpers.js +145 -0
- package/dist/testing.d.ts +10 -0
- package/dist/testing.js +3 -0
- package/dist/validate.d.ts +27 -0
- package/dist/validate.js +133 -0
- package/dist/yargs-burgee.d.ts +50 -0
- package/dist/yargs-burgee.js +104 -0
- package/dist/yargs-cliui.d.ts +56 -0
- package/dist/yargs-cliui.js +421 -0
- package/dist/yargs-command.d.ts +82 -0
- package/dist/yargs-command.js +414 -0
- package/dist/yargs-completion.d.ts +41 -0
- package/dist/yargs-completion.js +271 -0
- package/dist/yargs-factory.d.ts +193 -0
- package/dist/yargs-factory.js +1606 -0
- package/dist/yargs-helpers.d.ts +6 -0
- package/dist/yargs-helpers.js +2 -0
- package/dist/yargs-middleware.d.ts +32 -0
- package/dist/yargs-middleware.js +81 -0
- package/dist/yargs-parser.d.ts +41 -0
- package/dist/yargs-parser.js +929 -0
- package/dist/yargs-shim.d.ts +54 -0
- package/dist/yargs-shim.js +84 -0
- package/dist/yargs-usage.d.ts +42 -0
- package/dist/yargs-usage.js +479 -0
- package/dist/yargs-utils.d.ts +33 -0
- package/dist/yargs-utils.js +209 -0
- package/dist/yargs-validation.d.ts +26 -0
- package/dist/yargs-validation.js +261 -0
- package/dist/yargs-y18n.d.ts +21 -0
- package/dist/yargs-y18n.js +117 -0
- package/dist/yargs.d.ts +6 -0
- package/dist/yargs.js +8 -0
- package/locales/be.json +46 -0
- package/locales/cs.json +51 -0
- package/locales/de.json +46 -0
- package/locales/en.json +55 -0
- package/locales/es.json +46 -0
- package/locales/fi.json +49 -0
- package/locales/fr.json +53 -0
- package/locales/he.json +55 -0
- package/locales/hi.json +49 -0
- package/locales/hu.json +46 -0
- package/locales/id.json +50 -0
- package/locales/it.json +46 -0
- package/locales/ja.json +51 -0
- package/locales/ka.json +55 -0
- package/locales/ko.json +49 -0
- package/locales/nb.json +44 -0
- package/locales/nl.json +49 -0
- package/locales/nn.json +44 -0
- package/locales/pirate.json +13 -0
- package/locales/pl.json +49 -0
- package/locales/pt.json +45 -0
- package/locales/pt_BR.json +48 -0
- package/locales/ru.json +51 -0
- package/locales/th.json +46 -0
- package/locales/tr.json +48 -0
- package/locales/uk_UA.json +51 -0
- package/locales/uz.json +52 -0
- package/locales/zh_CN.json +48 -0
- package/locales/zh_TW.json +51 -0
- package/package.json +62 -9
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { isCommandBuilderCallback } from './yargs-command.js';
|
|
2
|
+
import { isPromise, parseCommand } from './yargs-utils.js';
|
|
3
|
+
export const completionShTemplate = `###-begin-{{app_name}}-completions-###
|
|
4
|
+
#
|
|
5
|
+
# yargs command completion script
|
|
6
|
+
#
|
|
7
|
+
# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
|
|
8
|
+
# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
|
|
9
|
+
#
|
|
10
|
+
_{{app_name}}_yargs_completions()
|
|
11
|
+
{
|
|
12
|
+
local cur_word args type_list
|
|
13
|
+
|
|
14
|
+
cur_word="\${COMP_WORDS[COMP_CWORD]}"
|
|
15
|
+
args=("\${COMP_WORDS[@]}")
|
|
16
|
+
|
|
17
|
+
# ask yargs to generate completions.
|
|
18
|
+
# see https://stackoverflow.com/a/40944195/7080036 for the spaces-handling awk
|
|
19
|
+
mapfile -t type_list < <({{app_path}} --get-yargs-completions "\${args[@]}")
|
|
20
|
+
mapfile -t COMPREPLY < <(compgen -W "$( printf '%q ' "\${type_list[@]}" )" -- "\${cur_word}" |
|
|
21
|
+
awk '/ / { print "\\""$0"\\"" } /^[^ ]+$/ { print $0 }')
|
|
22
|
+
|
|
23
|
+
# if no match was found, fall back to filename completion
|
|
24
|
+
if [ \${#COMPREPLY[@]} -eq 0 ]; then
|
|
25
|
+
COMPREPLY=()
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
return 0
|
|
29
|
+
}
|
|
30
|
+
complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
|
|
31
|
+
###-end-{{app_name}}-completions-###
|
|
32
|
+
`;
|
|
33
|
+
export const completionZshTemplate = `#compdef {{app_name}}
|
|
34
|
+
###-begin-{{app_name}}-completions-###
|
|
35
|
+
#
|
|
36
|
+
# yargs command completion script
|
|
37
|
+
#
|
|
38
|
+
# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
|
|
39
|
+
# or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.
|
|
40
|
+
#
|
|
41
|
+
_{{app_name}}_yargs_completions()
|
|
42
|
+
{
|
|
43
|
+
local reply
|
|
44
|
+
local si=$IFS
|
|
45
|
+
IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}"))
|
|
46
|
+
IFS=$si
|
|
47
|
+
if [[ \${#reply} -gt 0 ]]; then
|
|
48
|
+
_describe 'values' reply
|
|
49
|
+
else
|
|
50
|
+
_default
|
|
51
|
+
fi
|
|
52
|
+
}
|
|
53
|
+
if [[ "'\${zsh_eval_context[-1]}" == "loadautofunc" ]]; then
|
|
54
|
+
_{{app_name}}_yargs_completions "$@"
|
|
55
|
+
else
|
|
56
|
+
compdef _{{app_name}}_yargs_completions {{app_name}}
|
|
57
|
+
fi
|
|
58
|
+
###-end-{{app_name}}-completions-###
|
|
59
|
+
`;
|
|
60
|
+
export class Completion {
|
|
61
|
+
completionKey = 'get-yargs-completions';
|
|
62
|
+
aliases = null;
|
|
63
|
+
customCompletionFunction = null;
|
|
64
|
+
indexAfterLastReset = 0;
|
|
65
|
+
zshShell;
|
|
66
|
+
yargs;
|
|
67
|
+
usage;
|
|
68
|
+
command;
|
|
69
|
+
shim;
|
|
70
|
+
constructor(yargs, usage, command, shim) {
|
|
71
|
+
this.yargs = yargs;
|
|
72
|
+
this.usage = usage;
|
|
73
|
+
this.command = command;
|
|
74
|
+
this.shim = shim;
|
|
75
|
+
this.zshShell = (this.shim.getEnv('SHELL')?.includes('zsh') || this.shim.getEnv('ZSH_NAME')?.includes('zsh')) ?? false;
|
|
76
|
+
}
|
|
77
|
+
defaultCompletion(args, argv, current, done) {
|
|
78
|
+
const handlers = this.command.getCommandHandlers();
|
|
79
|
+
for (let i = 0, ii = args.length; i < ii; ++i) {
|
|
80
|
+
const handler = handlers[args[i]];
|
|
81
|
+
if (handler && handler.builder) {
|
|
82
|
+
const builder = handler.builder;
|
|
83
|
+
if (isCommandBuilderCallback(builder)) {
|
|
84
|
+
this.indexAfterLastReset = i + 1;
|
|
85
|
+
const y = this.yargs.getInternalMethods().reset();
|
|
86
|
+
builder(y, true);
|
|
87
|
+
return y.argv;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const completions = [];
|
|
92
|
+
this.commandCompletions(completions, args, current);
|
|
93
|
+
this.optionCompletions(completions, args, argv, current);
|
|
94
|
+
this.choicesFromOptionsCompletions(completions, args, argv, current);
|
|
95
|
+
this.choicesFromPositionalsCompletions(completions, args, argv, current);
|
|
96
|
+
done(null, completions);
|
|
97
|
+
}
|
|
98
|
+
commandCompletions(completions, args, current) {
|
|
99
|
+
const parentCommands = this.yargs.getInternalMethods().getContext().commands;
|
|
100
|
+
if (!/^-/.exec(current) && parentCommands.at(-1) !== current && !this.previousArgHasChoices(args)) {
|
|
101
|
+
this.usage.getCommands().forEach((usageCommand) => {
|
|
102
|
+
const commandName = parseCommand(usageCommand[0]).cmd;
|
|
103
|
+
if (args.indexOf(commandName) === -1) {
|
|
104
|
+
if (!this.zshShell)
|
|
105
|
+
completions.push(commandName);
|
|
106
|
+
else {
|
|
107
|
+
const desc = usageCommand[1] || '';
|
|
108
|
+
completions.push(`${commandName.replace(/:/g, '\\:')}:${desc}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
optionCompletions(completions, args, argv, current) {
|
|
115
|
+
if ((/^-/.exec(current) || (current === '' && completions.length === 0)) && !this.previousArgHasChoices(args)) {
|
|
116
|
+
const options = this.yargs.getOptions();
|
|
117
|
+
const positionalKeys = this.yargs.getGroups()[this.usage.getPositionalGroupName()] || [];
|
|
118
|
+
Object.keys(options.key).forEach((key) => {
|
|
119
|
+
const negable = !!options.configuration['boolean-negation'] && options.boolean.includes(key);
|
|
120
|
+
const isPositionalKey = positionalKeys.includes(key);
|
|
121
|
+
if (!isPositionalKey && !options.hiddenOptions.includes(key) && !this.argsContainKey(args, key, negable)) {
|
|
122
|
+
this.completeOptionKey(key, completions, current, negable && !!options.default[key]);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
choicesFromOptionsCompletions(completions, args, _argv, _current) {
|
|
128
|
+
if (this.previousArgHasChoices(args)) {
|
|
129
|
+
const choices = this.getPreviousArgChoices(args);
|
|
130
|
+
if (choices && choices.length > 0)
|
|
131
|
+
completions.push(...choices.map((c) => c.replace(/:/g, '\\:')));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
choicesFromPositionalsCompletions(completions, args, argv, current) {
|
|
135
|
+
if (current === '' && completions.length > 0 && this.previousArgHasChoices(args))
|
|
136
|
+
return;
|
|
137
|
+
const positionalKeys = this.yargs.getGroups()[this.usage.getPositionalGroupName()] || [];
|
|
138
|
+
const offset = Math.max(this.indexAfterLastReset, this.yargs.getInternalMethods().getContext().commands.length + 1);
|
|
139
|
+
const positionalKey = positionalKeys[argv._.length - offset - 1];
|
|
140
|
+
if (!positionalKey)
|
|
141
|
+
return;
|
|
142
|
+
const choices = this.yargs.getOptions().choices[positionalKey] || [];
|
|
143
|
+
for (const choice of choices) {
|
|
144
|
+
if (choice.startsWith(current))
|
|
145
|
+
completions.push(choice.replace(/:/g, '\\:'));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
getPreviousArgChoices(args) {
|
|
149
|
+
if (args.length < 1)
|
|
150
|
+
return undefined;
|
|
151
|
+
let previousArg = args.at(-1);
|
|
152
|
+
let filter = '';
|
|
153
|
+
if (!previousArg.startsWith('-') && args.length > 1) {
|
|
154
|
+
filter = previousArg;
|
|
155
|
+
previousArg = args.at(-2);
|
|
156
|
+
}
|
|
157
|
+
if (!previousArg.startsWith('-'))
|
|
158
|
+
return undefined;
|
|
159
|
+
const previousArgKey = previousArg.replace(/^-+/, '');
|
|
160
|
+
const options = this.yargs.getOptions();
|
|
161
|
+
const possibleAliases = [previousArgKey, ...(this.yargs.getAliases()[previousArgKey] || [])];
|
|
162
|
+
let choices;
|
|
163
|
+
for (const possibleAlias of possibleAliases) {
|
|
164
|
+
if (Object.prototype.hasOwnProperty.call(options.key, possibleAlias) && Array.isArray(options.choices[possibleAlias])) {
|
|
165
|
+
choices = options.choices[possibleAlias];
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (choices)
|
|
170
|
+
return choices.filter((choice) => !filter || choice.startsWith(filter));
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
previousArgHasChoices(args) {
|
|
174
|
+
const choices = this.getPreviousArgChoices(args);
|
|
175
|
+
return choices !== undefined && choices.length > 0;
|
|
176
|
+
}
|
|
177
|
+
argsContainKey(args, key, negable) {
|
|
178
|
+
const argsContains = (s) => args.indexOf((/^[^0-9]$/.test(s) ? '-' : '--') + s) !== -1;
|
|
179
|
+
if (argsContains(key))
|
|
180
|
+
return true;
|
|
181
|
+
if (negable && argsContains(`no-${key}`))
|
|
182
|
+
return true;
|
|
183
|
+
if (this.aliases) {
|
|
184
|
+
for (const alias of this.aliases[key]) {
|
|
185
|
+
if (argsContains(alias))
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
completeOptionKey(key, completions, current, negable) {
|
|
192
|
+
let keyWithDesc = key;
|
|
193
|
+
if (this.zshShell) {
|
|
194
|
+
const descs = this.usage.getDescriptions();
|
|
195
|
+
const aliasKey = this.aliases?.[key]?.find((alias) => {
|
|
196
|
+
const desc = descs[alias];
|
|
197
|
+
return typeof desc === 'string' && desc.length > 0;
|
|
198
|
+
});
|
|
199
|
+
const descFromAlias = aliasKey ? descs[aliasKey] : undefined;
|
|
200
|
+
const desc = descs[key] ?? descFromAlias ?? '';
|
|
201
|
+
keyWithDesc = `${key.replace(/:/g, '\\:')}:${desc.replace('__yargsString__:', '').replace(/(\r\n|\n|\r)/gm, ' ')}`;
|
|
202
|
+
}
|
|
203
|
+
const startsByTwoDashes = (s) => /^--/.test(s);
|
|
204
|
+
const isShortOption = (s) => /^[^0-9]$/.test(s);
|
|
205
|
+
const dashes = !startsByTwoDashes(current) && isShortOption(key) ? '-' : '--';
|
|
206
|
+
completions.push(dashes + keyWithDesc);
|
|
207
|
+
if (negable)
|
|
208
|
+
completions.push(`${dashes}no-${keyWithDesc}`);
|
|
209
|
+
}
|
|
210
|
+
customCompletion(args, argv, current, done) {
|
|
211
|
+
this.shim.assert.notStrictEqual(this.customCompletionFunction, null);
|
|
212
|
+
const fn = this.customCompletionFunction;
|
|
213
|
+
if (isSyncCompletionFunction(fn)) {
|
|
214
|
+
const result = fn(current, argv);
|
|
215
|
+
if (isPromise(result)) {
|
|
216
|
+
return result
|
|
217
|
+
.then((list) => {
|
|
218
|
+
this.shim.process.nextTick(() => {
|
|
219
|
+
done(null, list);
|
|
220
|
+
});
|
|
221
|
+
})
|
|
222
|
+
.catch((err) => {
|
|
223
|
+
this.shim.process.nextTick(() => {
|
|
224
|
+
done(err, undefined);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return done(null, result);
|
|
229
|
+
}
|
|
230
|
+
else if (isFallbackCompletionFunction(fn)) {
|
|
231
|
+
return fn(current, argv, (onCompleted = done) => this.defaultCompletion(args, argv, current, onCompleted), (completions) => {
|
|
232
|
+
done(null, completions);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return fn(current, argv, (completions) => {
|
|
236
|
+
done(null, completions);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
getCompletion(args, done) {
|
|
240
|
+
const current = args.length ? args.at(-1) : '';
|
|
241
|
+
const argv = this.yargs.parse(args, true);
|
|
242
|
+
const completionFunction = this.customCompletionFunction
|
|
243
|
+
? (a) => this.customCompletion(args, a, current, done)
|
|
244
|
+
: (a) => this.defaultCompletion(args, a, current, done);
|
|
245
|
+
return isPromise(argv) ? argv.then(completionFunction) : completionFunction(argv);
|
|
246
|
+
}
|
|
247
|
+
generateCompletionScript($0, cmd) {
|
|
248
|
+
let script = this.zshShell ? completionZshTemplate : completionShTemplate;
|
|
249
|
+
const name = this.shim.path.basename($0);
|
|
250
|
+
if (/\.js$/.exec($0))
|
|
251
|
+
$0 = `./${$0}`;
|
|
252
|
+
script = script.replace(/{{app_name}}/g, name);
|
|
253
|
+
script = script.replace(/{{completion_command}}/g, cmd);
|
|
254
|
+
return script.replace(/{{app_path}}/g, $0);
|
|
255
|
+
}
|
|
256
|
+
registerFunction(fn) {
|
|
257
|
+
this.customCompletionFunction = fn;
|
|
258
|
+
}
|
|
259
|
+
setParsed(parsed) {
|
|
260
|
+
this.aliases = parsed.aliases;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
export function completion(yargs, usage, command, shim) {
|
|
264
|
+
return new Completion(yargs, usage, command, shim);
|
|
265
|
+
}
|
|
266
|
+
function isSyncCompletionFunction(fn) {
|
|
267
|
+
return fn.length < 3;
|
|
268
|
+
}
|
|
269
|
+
function isFallbackCompletionFunction(fn) {
|
|
270
|
+
return fn.length > 3;
|
|
271
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* yargs' `YargsInstance`, ported method for method from yargs 18 and graded by yargs'
|
|
3
|
+
* own suite through `compat-oracle`. Every public method, its argsert contract, the
|
|
4
|
+
* parse pipeline, the freeze/unfreeze bookkeeping around `.parse()` and the
|
|
5
|
+
* `getInternalMethods()` seam are the upstream's — that is what makes a user's
|
|
6
|
+
* existing program run unchanged (J2).
|
|
7
|
+
*/
|
|
8
|
+
import { type Effects, Manifest, type Plugin } from './manifest.js';
|
|
9
|
+
import { type CommandInstance } from './yargs-command.js';
|
|
10
|
+
import { type CompletionFunction } from './yargs-completion.js';
|
|
11
|
+
import { type Middleware } from './yargs-middleware.js';
|
|
12
|
+
import type { PlatformShim } from './yargs-shim.js';
|
|
13
|
+
import { type FailureFunction, type UsageInstance } from './yargs-usage.js';
|
|
14
|
+
import { YError } from './yargs-utils.js';
|
|
15
|
+
import { type ValidationInstance } from './yargs-validation.js';
|
|
16
|
+
export interface Options {
|
|
17
|
+
array: string[];
|
|
18
|
+
boolean: string[];
|
|
19
|
+
string: string[];
|
|
20
|
+
skipValidation: string[];
|
|
21
|
+
count: string[];
|
|
22
|
+
normalize: string[];
|
|
23
|
+
number: string[];
|
|
24
|
+
hiddenOptions: string[];
|
|
25
|
+
narg: Record<string, number>;
|
|
26
|
+
key: Record<string, boolean>;
|
|
27
|
+
alias: Record<string, string[]>;
|
|
28
|
+
default: Record<string, any>;
|
|
29
|
+
defaultDescription: Record<string, string>;
|
|
30
|
+
config: Record<string, any>;
|
|
31
|
+
choices: Record<string, any[]>;
|
|
32
|
+
demandedOptions: Record<string, string | undefined>;
|
|
33
|
+
demandedCommands: Record<string, {
|
|
34
|
+
min: number;
|
|
35
|
+
max: number;
|
|
36
|
+
minMsg?: string | null | undefined;
|
|
37
|
+
maxMsg?: string | null | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
deprecatedOptions: Record<string, string | boolean | undefined>;
|
|
40
|
+
local: string[];
|
|
41
|
+
configObjects: Record<string, any>[];
|
|
42
|
+
envPrefix?: string | undefined;
|
|
43
|
+
showHiddenOpt: string;
|
|
44
|
+
configuration: Record<string, any>;
|
|
45
|
+
__?: (...args: any[]) => string;
|
|
46
|
+
}
|
|
47
|
+
export interface Context {
|
|
48
|
+
commands: string[];
|
|
49
|
+
fullCommands: string[];
|
|
50
|
+
}
|
|
51
|
+
interface Logger {
|
|
52
|
+
log: (...args: any[]) => void;
|
|
53
|
+
error: (...args: any[]) => void;
|
|
54
|
+
}
|
|
55
|
+
export type ParseCallback = (err: YError | string | undefined | null, argv: any, output: string) => void;
|
|
56
|
+
interface Writer {
|
|
57
|
+
write: (str: string) => unknown;
|
|
58
|
+
}
|
|
59
|
+
/** burgee's seam: inject the streams and the exit, and get E1 exit codes back (T1). */
|
|
60
|
+
export interface BurgeeSeam {
|
|
61
|
+
stdout?: Writer;
|
|
62
|
+
stderr?: Writer;
|
|
63
|
+
exit?: (code: number) => void;
|
|
64
|
+
}
|
|
65
|
+
export declare function YargsFactory(shim: PlatformShim): (processArgs?: string | string[], cwd?: string, parentRequire?: NodeJS.Require) => YargsInstance;
|
|
66
|
+
export declare class YargsInstance {
|
|
67
|
+
#private;
|
|
68
|
+
$0: string;
|
|
69
|
+
argv?: any;
|
|
70
|
+
customScriptName: boolean;
|
|
71
|
+
parsed: any;
|
|
72
|
+
constructor(processArgs: string | string[] | undefined, cwd: string, parentRequire: NodeJS.Require | undefined, shim: PlatformShim);
|
|
73
|
+
addHelpOpt(opt?: string | false, msg?: string): this;
|
|
74
|
+
help(opt?: string | false, msg?: string): this;
|
|
75
|
+
addShowHiddenOpt(opt?: string | false, msg?: string): this;
|
|
76
|
+
showHidden(opt?: string | false, msg?: string): this;
|
|
77
|
+
alias(key: string | string[] | Record<string, string | string[]>, value?: string | string[]): this;
|
|
78
|
+
array(keys: string | string[]): this;
|
|
79
|
+
boolean(keys: string | string[]): this;
|
|
80
|
+
check(f: (argv: any, options: Options) => any, global?: boolean): this;
|
|
81
|
+
choices(key: string | string[] | Record<string, any>, value?: any): this;
|
|
82
|
+
coerce(keys: string | string[] | Record<string, (arg: any) => any>, value?: (arg: any) => any): this;
|
|
83
|
+
conflicts(key1: string | Record<string, string | string[]>, key2?: string | string[]): this;
|
|
84
|
+
config(key?: string | string[] | Record<string, any>, msg?: string | ((path: string) => any), parseFn?: (path: string) => any): this;
|
|
85
|
+
completion(cmd?: string, desc?: string | false | CompletionFunction, fn?: CompletionFunction): this;
|
|
86
|
+
command(cmd: any, description?: any, builder?: any, handler?: any, middlewares?: Middleware[], deprecated?: boolean | string): this;
|
|
87
|
+
commands(cmd: any, description?: any, builder?: any, handler?: any, middlewares?: Middleware[], deprecated?: boolean | string): this;
|
|
88
|
+
commandDir(dir: string, opts?: any): this;
|
|
89
|
+
count(keys: string | string[]): this;
|
|
90
|
+
default(key: string | string[] | Record<string, any>, value?: any, defaultDescription?: string): this;
|
|
91
|
+
defaults(key: string | string[] | Record<string, any>, value?: any, defaultDescription?: string): this;
|
|
92
|
+
demandCommand(min?: number, max?: number | string | null, minMsg?: string | null, maxMsg?: string | null): this;
|
|
93
|
+
demand(keys: string | string[] | number | Record<string, any>, max?: number | string | string[] | boolean, msg?: string | boolean): this;
|
|
94
|
+
demandOption(keys: string | string[] | Record<string, string | undefined>, msg?: string): this;
|
|
95
|
+
deprecateOption(option: string, message?: string | boolean): this;
|
|
96
|
+
describe(keys: string | string[] | Record<string, string>, description?: string): this;
|
|
97
|
+
detectLocale(detect: boolean): this;
|
|
98
|
+
env(prefix?: string | false): this;
|
|
99
|
+
epilogue(msg: string): this;
|
|
100
|
+
epilog(msg: string): this;
|
|
101
|
+
example(cmd: string | [string, string?][], description?: string): this;
|
|
102
|
+
exit(code: number, err?: YError | string): void;
|
|
103
|
+
exitProcess(enabled?: boolean): this;
|
|
104
|
+
fail(f: FailureFunction | boolean): this;
|
|
105
|
+
getAliases(): Record<string, string[]>;
|
|
106
|
+
getCompletion(args: string[], done?: (err: Error | null, completions: string[] | undefined) => void): Promise<string[] | void>;
|
|
107
|
+
getDemandedOptions(): Record<string, string | undefined>;
|
|
108
|
+
getDemandedCommands(): Options['demandedCommands'];
|
|
109
|
+
getDeprecatedOptions(): Options['deprecatedOptions'];
|
|
110
|
+
getDetectLocale(): boolean;
|
|
111
|
+
getExitProcess(): boolean;
|
|
112
|
+
getGroups(): Record<string, string[]>;
|
|
113
|
+
getHelp(): Promise<string>;
|
|
114
|
+
getOptions(): Options;
|
|
115
|
+
getStrict(): boolean;
|
|
116
|
+
getStrictCommands(): boolean;
|
|
117
|
+
getStrictOptions(): boolean;
|
|
118
|
+
global(globals: string | string[], global?: boolean): this;
|
|
119
|
+
group(opts: string | string[], groupName: string): this;
|
|
120
|
+
hide(key: string): this;
|
|
121
|
+
implies(key: string | Record<string, any>, value?: number | string | string[]): this;
|
|
122
|
+
locale(locale?: string): this | string;
|
|
123
|
+
middleware(callback: Middleware | Middleware[], applyBeforeValidation?: boolean, global?: boolean): this;
|
|
124
|
+
nargs(key: string | string[] | Record<string, number>, value?: number): this;
|
|
125
|
+
normalize(keys: string | string[]): this;
|
|
126
|
+
number(keys: string | string[]): this;
|
|
127
|
+
option(key: string | Record<string, any>, opt?: any): this;
|
|
128
|
+
options(key: string | Record<string, any>, opt?: any): this;
|
|
129
|
+
parse(args?: string | string[], shortCircuit?: object | ParseCallback | boolean, _parseFn?: ParseCallback): any;
|
|
130
|
+
parseAsync(args?: string | string[], shortCircuit?: object | ParseCallback | boolean, _parseFn?: ParseCallback): Promise<any>;
|
|
131
|
+
parseSync(args?: string | string[], shortCircuit?: object | ParseCallback | boolean, _parseFn?: ParseCallback): any;
|
|
132
|
+
parserConfiguration(config: Record<string, any>): this;
|
|
133
|
+
pkgConf(key: string, rootPath?: string): this;
|
|
134
|
+
positional(key: string, opts: Record<string, any>): this;
|
|
135
|
+
recommendCommands(recommend?: boolean): this;
|
|
136
|
+
required(keys: string | string[] | number | Record<string, any>, max?: number | string | string[] | boolean, msg?: string | boolean): this;
|
|
137
|
+
require(keys: string | string[] | number | Record<string, any>, max?: number | string | string[] | boolean, msg?: string | boolean): this;
|
|
138
|
+
requiresArg(keys: string | string[] | Record<string, any>): this;
|
|
139
|
+
showCompletionScript($0?: string, cmd?: string): this;
|
|
140
|
+
showHelp(level?: 'error' | 'log' | ((message: string) => void)): this;
|
|
141
|
+
scriptName(scriptName: string): this;
|
|
142
|
+
showHelpOnFail(enabled?: string | boolean, message?: string): this;
|
|
143
|
+
showVersion(level?: 'error' | 'log' | ((message: string) => void)): this;
|
|
144
|
+
skipValidation(keys: string | string[]): this;
|
|
145
|
+
strict(enabled?: boolean): this;
|
|
146
|
+
strictCommands(enabled?: boolean): this;
|
|
147
|
+
strictOptions(enabled?: boolean): this;
|
|
148
|
+
string(keys: string | string[]): this;
|
|
149
|
+
terminalWidth(): number | null;
|
|
150
|
+
updateLocale(obj: Record<string, any>): this;
|
|
151
|
+
updateStrings(obj: Record<string, any>): this;
|
|
152
|
+
usage(msg: string | null, description?: string | false, builder?: any, handler?: any): this;
|
|
153
|
+
usageConfiguration(config: Record<string, any>): this;
|
|
154
|
+
version(opt?: string | false, msg?: string, ver?: string): this;
|
|
155
|
+
wrap(cols: number | null | undefined): this;
|
|
156
|
+
getInternalMethods(): {
|
|
157
|
+
getCommandInstance: () => CommandInstance;
|
|
158
|
+
getContext: () => Context;
|
|
159
|
+
getHasOutput: () => boolean;
|
|
160
|
+
getLoggerInstance: () => Logger;
|
|
161
|
+
getParseContext: () => object;
|
|
162
|
+
getParserConfiguration: () => Record<string, any>;
|
|
163
|
+
getUsageConfiguration: () => Record<string, any>;
|
|
164
|
+
getUsageInstance: () => UsageInstance;
|
|
165
|
+
getValidationInstance: () => ValidationInstance;
|
|
166
|
+
hasParseCallback: () => boolean;
|
|
167
|
+
isGlobalContext: () => boolean;
|
|
168
|
+
postProcess: (argv: any, populateDoubleDash: boolean, calledFromCommand: boolean, runGlobalMiddleware: boolean) => any;
|
|
169
|
+
reset: (aliases?: Record<string, string[]>) => YargsInstance;
|
|
170
|
+
runValidation: (aliases: Record<string, string[]>, positionalMap: Record<string, string[]>, parseErrors: Error | null, isDefaultCommand?: boolean) => (argv: any) => void;
|
|
171
|
+
runYargsParserAndExecuteCommands: (args: string | string[] | null, shortCircuit?: boolean, calledFromCommand?: boolean, commandIndex?: number, helpOnly?: boolean) => any;
|
|
172
|
+
setHasOutput: () => void;
|
|
173
|
+
runHandler: (handler: (argv: any) => any, argv: any, original: string) => any;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* The manifest every surface reads (J7, J8). Projected on each access from what the
|
|
177
|
+
* program registered; a command's builder is run on a scratch instance to learn its
|
|
178
|
+
* options, exactly as yargs' own completion does. Plugin-contributed nodes are kept.
|
|
179
|
+
*/
|
|
180
|
+
get manifest(): Manifest;
|
|
181
|
+
/** burgee: declare what the command does to the world (N6); what exposes it as an MCP tool (N2). */
|
|
182
|
+
effects(value: Effects): this;
|
|
183
|
+
/** Additive: plugins yargs never had. `preRun`/`postRun` fire around every handler. */
|
|
184
|
+
use(plugin: Plugin): this;
|
|
185
|
+
/**
|
|
186
|
+
* Inject the streams and the exit for this instance (T1). Output goes to `stdout`/`stderr`
|
|
187
|
+
* instead of the console, and `exit` receives an E1 code: OK for help and version, USAGE
|
|
188
|
+
* for a validation failure, RUNTIME for a handler that threw.
|
|
189
|
+
*/
|
|
190
|
+
burgee(seam: BurgeeSeam): this;
|
|
191
|
+
}
|
|
192
|
+
export declare function isYargsInstance(y: any): y is YargsInstance;
|
|
193
|
+
export {};
|