-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrau.ts
144 lines (140 loc) · 4.91 KB
/
rau.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
const BASEPATH = "/Users/n/.rau/";
const completionSpec: Fig.Spec = {
name: "rau",
description: "CLI for interacting with Airtable",
args: [
{
name: "config",
description: "The name of the configuration to use",
isOptional: false,
generators: {
script: [`awk`, `-F=`, `/^[a-zA-Z0-9_-]+/`, `${BASEPATH}config.toml`],
postProcess: (out) => {
return out
.split("\n")
.filter((line) => line.trim() && !line.startsWith("api_key"))
.map((line) => ({
name: line.split("=")[0].trim(),
description: "Configuration name",
}));
},
},
},
{
name: "record_id",
description: "The ID of the record to update or query",
isOptional: true,
generators: {
script: (tokens) => {
const config = tokens[1];
if (config) {
return [`${BASEPATH}rau_fetch_records.sh`, config];
}
return [""];
},
postProcess: (out) => {
return out.split("\n").map((line) => {
const [id, name] = line.split(",", 2);
return {
name: name.replace(/"/g, "").trim(),
insertValue: id,
description: id,
};
});
},
},
},
{
name: "fields",
description: "Fields to update in key=value format or fields to query for their values",
isOptional: true,
isVariadic: true,
generators: {
script: (tokens) => {
const config = tokens[1];
if (config) {
return [`${BASEPATH}rau_fetch_fields.sh`, config];
}
return [""];
},
postProcess: (out) => {
return out.split("\n").map((line) => ({
name: line.trim(),
description: "Field name",
}));
},
},
},
],
};
export default completionSpec;
const BASEPATH = "/Users/n/.rau/";
const completionSpec: Fig.Spec = {
name: "rau",
description: "CLI for interacting with Airtable",
args: [
{
name: "config",
description: "The name of the configuration to use",
isOptional: false,
generators: {
script: [`awk`, `-F=`, `/^[a-zA-Z0-9_-]+/`, `${BASEPATH}config.toml`],
postProcess: (out) => {
return out
.split("\n")
.filter((line) => line.trim() && !line.startsWith("api_key"))
.map((line) => ({
name: line.split("=")[0].trim(),
description: "Configuration name",
}));
},
},
},
{
name: "record_id",
description: "The ID of the record to update or query",
isOptional: true,
generators: {
script: (tokens) => {
const config = tokens[1];
if (config) {
return [`${BASEPATH}rau_fetch_records.sh`, config];
}
return [""];
},
postProcess: (out) => {
return out.split("\n").map((line) => {
const [id, name] = line.split(",", 2);
return {
name: name.replace(/"/g, "").trim(),
insertValue: id,
description: id,
};
});
},
},
},
{
name: "fields",
description: "Fields to update in key=value format or fields to query for their values",
isOptional: true,
isVariadic: true,
generators: {
script: (tokens) => {
const config = tokens[1];
if (config) {
return [`${BASEPATH}rau_fetch_fields.sh`, config];
}
return [""];
},
postProcess: (out) => {
return out.split("\n").map((line) => ({
name: line.trim(),
description: "Field name",
}));
},
},
},
],
};
export default completionSpec;