forked from withfig/autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharch.ts
84 lines (81 loc) · 2.05 KB
/
arch.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const archNames: { name: string; description: string }[] = [
{ name: "i386", description: "32-bit intel" },
{ name: "x86_64", description: "64-bit intel" },
{ name: "x86_64h", description: "64-bit intel (haswell)" },
{ name: "arm64", description: "64-bit arm" },
{ name: "arm64e", description: "64-bit arm (Apple Silicon)" },
];
const archOptions: Fig.Option[] = archNames.map((arch) => ({
name: "-" + arch.name,
description: arch.description,
isRepeatable: true,
exclusiveOn: ["-arch"],
icon: "fig://icon?type=cpu",
}));
const archOption: Fig.Option = {
name: "-arch",
isRepeatable: true,
exclusiveOn: archOptions.map(({ name }) => name as string),
args: {
name: "arch_name",
suggestions: archNames.map((arch) => ({
...arch,
icon: "fig://icon?type=cpu",
})),
},
};
const completionSpec: Fig.Spec = {
name: "arch",
description: "Print architecture type or run select architecture",
parserDirectives: {
flagsArePosixNoncompliant: true,
optionsMustPrecedeArguments: true,
},
options: [
{
name: "-32",
description:
"Add the native 32-bit architecture to the list of architectures",
},
{
name: "-64",
description:
"Add the native 64-bit architecture to the list of architectures",
},
archOption,
...archOptions,
{
name: "-c",
description: "Clear the environment that will be passed to the command",
},
{
name: "-d",
description:
"Delete the named environment variable from the command's environment",
isRepeatable: true,
args: {
name: "envname",
},
},
{
name: "-e",
description:
"Assign the given value to the variable in the command's environment",
isRepeatable: true,
args: {
name: "envname=value",
},
},
{
name: "-h",
description: "Print a help message and exit",
},
],
args: {
name: "program",
template: "filepaths",
isCommand: true,
isVariadic: true,
},
};
export default completionSpec;