-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathsurreal.ts
266 lines (264 loc) · 7.9 KB
/
surreal.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
const authOptions: Fig.Option[] = [
{
name: ["--pass", "-p"],
description:
"Database authentication password to use when connecting [default: root]",
args: {
name: "pass",
description:
"Database authentication password to use when connecting [default: root]",
},
},
{
name: ["--user", "-u"],
description:
"Database authentication username to use when connecting [default: root]",
args: {
name: "user",
description:
"Database authentication username to use when connecting [default: root]",
},
},
];
const connectionOptionsAndArgs = (
state: string,
preposition: string
): Partial<Fig.Subcommand> => ({
options: [
...authOptions,
{
name: ["--conn", "-c"],
description:
"Remote database server url to connect to [default: https://cloud.surrealdb.com]",
args: {
name: "conn",
description:
"Remote database server url to connect to [default: https://cloud.surrealdb.com]",
},
},
{
name: "--ns",
description: `The namespace to ${state} the data ${preposition}`,
isRequired: true,
args: {
name: "ns",
description: `The namespace to ${state} the data ${preposition}`,
},
},
{
name: "--db",
description: `The database to ${state} the data ${preposition}`,
isRequired: true,
args: {
name: "db",
description: `The database to ${state} the data ${preposition}`,
},
},
],
args: {
name: "file",
description: `Path to the sql file to ${state}`,
},
});
const completionSpec: Fig.Spec = {
name: "surreal",
description:
"SurrealDB is the ultimate cloud database for tomorrow's applications - https://surrealdb.com/",
subcommands: [
{
name: "help",
description: "Print this message or the help of the given subcommand(s)",
args: {
name: "command",
isOptional: true,
template: "help",
description: "Command to get help for",
},
},
{
name: "start",
description: "Start the database server",
args: {
name: "path",
description:
"Database path used for storing data [env: DB_PATH=] [default: memory]",
isOptional: true,
},
options: [
{
name: "--",
description: "Everything after this is an argument",
},
{
name: "--addr",
description:
"The allowed networks for master authentication [env: ADDR=] [default: 127.0.0.1/32]",
args: {
name: "addr",
description:
"The allowed networks for master authentication [env: ADDR=] [default: 127.0.0.1/32]",
},
},
{
name: ["--bind", "-b"],
description:
"The hostname or ip address to listen for connections on [env: BIND=] [default: 0.0.0.0:8000]",
args: {
name: "bind",
description:
"The hostname or ip address to listen for connections on [env: BIND=] [default: 0.0.0.0:8000]",
},
},
{
name: ["--key", "-k"],
description:
"Encryption key to use for on-disk encryption [env: KEY=]",
args: {
name: "key",
description:
"Encryption key to use for on-disk encryption [env: KEY=]",
},
},
{
name: "--kvs-ca",
description:
"Path to the CA file used when connecting to the remote KV store [env: KVS_CA=]",
args: {
name: "kvs-ca",
description:
"Path to the CA file used when connecting to the remote KV store [env: KVS_CA=]",
},
},
{
name: "--kvs-crt",
description:
"Path to the certificate file used when connecting to the remote KV store [env: KVS_CRT=]",
args: {
name: "kvs-crt",
description:
"Path to the certificate file used when connecting to the remote KV store [env: KVS_CRT=]",
},
},
{
name: "--kvs-key",
description:
"Path to the private key file used when connecting to the remote KV store [env: KVS_KEY=]",
args: {
name: "kvs-key",
description:
"Path to the private key file used when connecting to the remote KV store [env: KVS_KEY=]",
},
},
{
name: ["--log", "-l"],
description:
"The logging level for the database server [env: LOG=] [default: info] [possible values: warn, info, debug, trace, full]",
args: {
name: "log",
description:
"The logging level for the database server [env: LOG=] [default: info] [possible values: warn, info, debug, trace, full]",
suggestions: ["warn", "info", "debug", "trace", "full"],
},
},
{
name: ["--pass", "-p"],
description: "The master password for the database [env: PASS=]",
args: {
name: "pass",
description: "The master password for the database [env: PASS=]",
},
},
{
name: ["--strict", "-s"],
description:
"Whether strict mode is enabled on this database instance [env: STRICT=]",
args: {
name: "strict",
description:
"Whether strict mode is enabled on this database instance [env: STRICT=]",
},
},
{
name: ["--user", "-u"],
description:
"The master username for the database [env: USER=] [default: root]",
args: {
name: "user",
description:
"The master username for the database [env: USER=] [default: root]",
},
},
{
name: "--web-crt",
description:
"Path to the certificate file for encrypted client connections [env: WEB_CRT=]",
args: {
name: "web-crt",
description:
"Path to the certificate file for encrypted client connections [env: WEB_CRT=]",
},
},
{
name: "--web-key",
description:
"Path to the private key file for encrypted client connections [env: WEB_KEY=]",
args: {
name: "web-key",
description:
"Path to the private key file for encrypted client connections [env: WEB_KEY=]",
},
},
],
},
{
name: "backup",
description: "Backup data to or from an existing database",
args: [
{
name: "from",
description:
"Path to the remote database or file from which to export",
},
{
name: "into",
description:
"Path to the remote database or file into which to import",
},
],
options: authOptions,
},
{
name: "import",
description: "Import a SurrealQL script into an existing database",
...connectionOptionsAndArgs("import", "into"),
},
{
name: "export",
description: "Export an existing database as a SurrealQL script",
...connectionOptionsAndArgs("export", "from"),
},
{
name: "version",
description: "Output the command-line tool version information",
},
{
name: "sql",
description: "Start an SQL REPL in your terminal with pipe support",
options: [
...connectionOptionsAndArgs("export", "from").options,
{
name: "--pretty",
description: "Whether database responses should be pretty printed",
},
],
args: connectionOptionsAndArgs("export", "from").args,
},
],
options: [
{
name: ["--help", "-h"],
description: "Print help information",
},
],
};
export default completionSpec;