-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathmask.ts
43 lines (37 loc) · 1.28 KB
/
mask.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
// To learn more about Fig's autocomplete standard visit: https://fig.io/docs/concepts/cli-skeleton
// var executeShellCommand: Fig.ExecuteShellCommandFunction;
// The below is a dummy example for git. Make sure to change the file name!
const completionSpec: Fig.Spec = {
name: "mask",
generateSpec: async (tokens, executeShellCommand) => {
// See if use specified a maskfile location
var maskfileLocationIdx = tokens.indexOf("--maskfile");
var out: string;
// mask --maskfile path/tp/thing build
if (maskfileLocationIdx < 0 || maskfileLocationIdx + 3 > tokens.length) {
const { stdout } = await executeShellCommand({
command: "cat",
// eslint-disable-next-line @withfig/fig-linter/no-useless-arrays
args: ["maskfile.md"],
});
out = stdout;
} else {
const { stdout } = await executeShellCommand({
command: "cat",
// eslint-disable-next-line @withfig/fig-linter/no-useless-arrays
args: [tokens[maskfileLocationIdx + 1]],
});
out = stdout;
}
if (out === "") return { name: "null" };
return {
name: "mask",
subcommands: out.match(/##.*/g).map((elm) => {
return {
name: elm.slice(3),
};
}),
};
},
};
export default completionSpec;