-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathphp.ts
60 lines (55 loc) · 1.6 KB
/
php.ts
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
54
55
56
57
58
59
60
// To learn more about Fig's autocomplete standard visit: https://fig.io/docs/concepts/cli-skeleton
const fileExists = async (
executeCommand: Fig.ExecuteCommandFunction,
file: string
) => {
return (
// eslint-disable-next-line @withfig/fig-linter/no-useless-arrays
(await executeCommand({ command: "ls", args: [file] })).status === 0
);
};
const completionSpec: Fig.Spec = {
name: "php",
description: "Run the PHP interpreter",
generateSpec: async (tokens, executeShellCommand) => {
const subcommands = [];
await Promise.all([
(async () => {
if (await fileExists(executeShellCommand, "artisan")) {
subcommands.push({ name: "artisan", loadSpec: "php/artisan" });
}
})(),
(async () => {
if (await fileExists(executeShellCommand, "please")) {
subcommands.push({ name: "please", loadSpec: "php/please" });
}
})(),
(async () => {
if (await fileExists(executeShellCommand, "bin/console")) {
subcommands.push({
name: "bin/console",
loadSpec: "php/bin-console",
});
}
})(),
]);
return {
name: "php",
subcommands,
args: {
generators: {
template: "filepaths",
filterTemplateSuggestions: function (suggestions) {
return suggestions.filter((suggestion) => {
return (
// suggestion.name.endsWith(".php") ||
suggestion.name.indexOf(".") === -1
);
});
},
},
},
};
},
};
export default completionSpec;