forked from withfig/autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefaults.ts
201 lines (184 loc) · 4.32 KB
/
defaults.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
const domain: Fig.Arg = {
name: "domain",
generators: {
script: "defaults domains",
postProcess: function (out) {
return out.split(",").map((domain) => {
return {
name: domain.trim(),
};
});
},
},
suggestions: [
{
name: "-globalDomain",
description: "Global domain",
},
{
name: "-app",
insertValue: "-app '{cursor}'",
description: "Application name",
},
],
};
const key: Fig.Arg = {
name: "key",
};
const value: Fig.Arg = {
name: "value",
};
const valueArgs = [
{
name: "-string",
args: {
name: "string_value",
},
},
{
name: "-data",
args: {
name: "hex_digits",
},
},
{
name: ["-int", "-integer"],
args: {
name: "integer_value",
},
},
{
name: "-float",
args: {
name: "floating-point_value",
},
},
{
name: ["-bool", "-boolean"],
args: {
suggestions: [
{
name: "true",
},
{
name: "false",
},
{
name: "yes",
},
{
name: "no",
},
],
},
},
{
name: "-date",
args: {
name: "date_rep",
},
},
{
name: "-array",
args: {
isVariadic: true,
name: "array_item",
},
},
{
name: "-array-add",
args: {
isVariadic: true,
name: "array_item",
},
},
];
const completionSpec: Fig.Spec = {
name: "defaults",
description: "Command line interface to a user's defaults",
subcommands: [
{
name: "read",
description: "Shows defaults",
args: [domain, key],
},
{
name: "write",
description: "Writes key for domain",
args: [domain, key, value],
},
{
name: "delete",
description: "Deletes domain or key in domain",
args: [domain, key],
},
{
name: "rename",
description: "Renames old_key to new_key",
args: [
domain,
{
name: "old_key",
},
{
name: "new_key",
},
],
},
{
name: "domains",
description: "Lists all domains",
},
{
name: "find",
description: "Lists all entries containing word",
args: {
name: "word",
description: "The word to search for",
},
},
{
name: "help",
description: "Show help text",
},
{
name: "read-type",
description: "Shows the type for the given domain, key",
args: [domain, key],
},
],
};
// Command line interface to a user's defaults.
// Syntax:
// 'defaults' [-currentHost | -host <hostname>] followed by one of the following:
// read shows all defaults
// read <domain> shows defaults for given domain
// read <domain> <key> shows defaults for given domain, key
// read-type <domain> <key> shows the type for the given domain, key
// write <domain> <domain_rep> writes domain (overwrites existing)
// write <domain> <key> <value> writes key for domain
// rename <domain> <old_key> <new_key> renames old_key to new_key
// delete <domain> deletes domain
// delete <domain> <key> deletes key in domain
// import <domain> <path to plist> writes the plist at path to domain
// import <domain> - writes a plist from stdin to domain
// export <domain> <path to plist> saves domain as a binary plist to path
// export <domain> - writes domain as an xml plist to stdout
// domains lists all domains
// find <word> lists all entries containing word
// help print this help
// <domain> is ( <domain_name> | -app <application_name> | -globalDomain )
// or a path to a file omitting the '.plist' extension
// <value> is one of:
// <value_rep>
// -string <string_value>
// -data <hex_digits>
// -int[eger] <integer_value>
// -float <floating-point_value>
// -bool[ean] (true | false | yes | no)
// -date <date_rep>
// -array <value1> <value2> ...
// -array-add <value1> <value2> ...
// -dict <key1> <value1> <key2> <value2> ...
// -dict-add <key1> <value1> ...
export default completionSpec;