forked from withfig/autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfvm.ts
181 lines (178 loc) · 4.67 KB
/
fvm.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
const semverRegex = /((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)/gm;
const globalOptions: Fig.Option[] = [
{
name: ["-h", "--help"],
description: "Print this usage information",
},
];
const completionSpec: Fig.Spec = {
name: "fvm",
description:
"Flutter Version Management: A cli to manage Flutter SDK versions",
options: [
...globalOptions,
{
name: "--verbose",
description: "Print verbose output",
},
{
name: "--version",
description: "Current FVM version",
},
],
subcommands: [
{
name: "config",
description: "Set configuration for FVM",
options: [
...globalOptions,
{
name: ["-c", "--cache-path"],
description:
"Set the path which FVM will cache the version. Priority over FVM_HOME",
args: {
name: "path",
description: "Path to the Flutter versions cache",
template: "filepaths",
},
},
{
name: ["-s", "--skip-setup", "--no-skip-setup"],
description: "Skip setup after a version install",
},
{
name: ["-g", "--git-cache", "--no-git-cache"],
description:
"ADVANCED: Will cache a local version of Flutter repo for faster version install",
},
],
},
{
name: "dart",
description: "Proxies Dart commands",
},
{
name: "doctor",
description:
"Shows information about environment, and project configuration",
},
{
name: "flavor",
description: "Switches between different project flavors",
args: {
name: "flavor-name",
description: "The flavor to switch to",
},
},
{
name: "flutter",
description: "Proxies Flutter commands",
loadSpec: "flutter",
},
{
name: "global",
description: "Sets Flutter SDK version as global",
args: {
name: "version",
description: "Flutter SDK to set for global flutter command",
},
},
{
name: "install",
description: "Installs Flutter SDK version",
args: {
name: "version",
suggestions: [
{
name: "stable",
description: "Latest stable release of Flutter",
priority: 100,
},
{
name: "beta",
description: "Latest beta release of Flutter",
priority: 99,
},
{
name: "dev",
description: "Latest dev release of Flutter (master)",
priority: 98,
},
],
generators: {
script: "fvm releases",
postProcess: function (out): Fig.Suggestion[] {
const matches = out.match(semverRegex);
const matchesSet = [...new Set(matches)];
return matchesSet.map((match) => ({ name: match })).reverse();
},
},
},
options: [
...globalOptions,
{
name: ["-s", "--skip-setup"],
description: "Skips Flutter setup after install",
},
],
},
{
name: "list",
description: "Lists installed Flutter SDK versions",
options: [...globalOptions],
},
{
name: "releases",
description: "View all Flutter SDK releases available for install",
options: [...globalOptions],
},
{
name: "remove",
description: "Removes Flutter SDK version",
args: {
name: "version",
description: "The installed Flutter version to remove",
},
options: [
...globalOptions,
{
name: "--force",
description: "Skips version global check",
},
],
},
{
name: "spawn",
description: "Spawn a Flutter SDK version command",
args: {
name: "version",
description: "The Flutter version from which to spawn a command",
},
},
{
name: "use",
description: "Sets a Flutter SDK version to be used in a project",
args: {
name: "version",
description: "The Flutter SDK version to use",
},
options: [
...globalOptions,
{
name: ["-f", "--force"],
description: "Skips command guards that does Flutter project checks",
},
{
name: ["-p", "--pin"],
description:
"If version provided is a channel. Will pin the latest release of the channel",
},
{
name: "--flavor",
description: "Sets version for a project flavor",
},
],
},
],
};
export default completionSpec;