forked from withfig/autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathartisan.ts
More file actions
53 lines (45 loc) · 1.44 KB
/
artisan.ts
File metadata and controls
53 lines (45 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const completionSpec: Fig.Spec = {
name: "artisan",
description: "Laravel Artisan Command",
generateSpec: async (tokens, executeShellCommand) => {
var out = await executeShellCommand("php artisan list --format=json");
const subcommands = [];
try {
const commandDefinition = JSON.parse(out);
commandDefinition.commands.map((command) => {
subcommands.push({
name: command.name,
description: command.description,
icon: "https://web.tinkerwell.app/img/laravel.3cab6a56.png",
args: Object.keys(command.definition.arguments).map((argumentKey) => {
const argument = command.definition.arguments[argumentKey];
return {
name: argument.name,
description: argument.description,
isOptional: !argument.is_required,
};
}),
options: Object.keys(command.definition.options).map((optionKey) => {
const option = command.definition.options[optionKey];
const names = [option.name];
if (option.shortcut !== "") {
names.push(option.shortcut);
}
return {
name: names,
description: option.description,
};
}),
});
});
} catch (err) {
//
}
return {
name: "artisan",
debounce: true,
subcommands,
};
},
};
export default completionSpec;