-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathipatool.ts
203 lines (196 loc) · 4.68 KB
/
ipatool.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
type SearchResult = {
level: string;
count: number;
apps: App[];
time: string;
};
type App = {
id: number;
bundleID: string;
name: string;
version: string;
price: number;
};
const bundleIdentifierGenerator: Fig.Generator = {
script: (context) => {
const identifier = context[context.length - 1];
if (!identifier) return undefined;
return [
"ipatool",
"search",
identifier,
"--limit",
"10",
"--format",
"json",
];
},
postProcess: (output) => {
if (!output) return [];
try {
const { apps } = JSON.parse(output) as SearchResult;
return apps.map((app) => ({
name: app.bundleID,
description: `${app.name} - ${app.version}`,
}));
} catch (error) {
return [];
}
},
};
const bundleIdentifierOption: Fig.Option = {
name: ["-b", "--bundle-identifier"],
description: "Bundle identifier of the app",
isRequired: true,
args: {
name: "identifier",
generators: bundleIdentifierGenerator,
filterStrategy: "fuzzy",
debounce: true,
},
};
const completionSpec: Fig.Spec = {
name: "ipatool",
displayName: "IPATool",
description:
"IPATool is a command line tool that allows you to search for iOS apps on the App Store and download a copy of the app package, known as an ipa file",
subcommands: [
{
name: "auth",
description: "Authenticate with the App Store",
subcommands: [
{
name: "info",
description: "Show current account info",
},
{
name: "login",
description: "Login to the App Store",
options: [
{
name: "--auth-code",
description: "2FA code for the Apple ID",
args: {
name: "2FA code",
},
},
{
name: ["-e", "--email"],
description: "Apple ID email address",
isRequired: true,
},
{
name: ["-p", "--password"],
description: "Apple ID password",
isRequired: true,
},
],
},
{
name: "revoke",
description: "Revoke your App Store credentials",
},
],
},
{
name: "completion",
description: "Generate shell completion script",
subcommands: [
{
name: "bash",
description: "Generate the autocompletion script for bash",
},
{
name: "fish",
description: "Generate the autocompletion script for fish",
},
{
name: "powershell",
description: "Generate the autocompletion script for powershell",
},
{
name: "zsh",
description: "Generate the autocompletion script for zsh",
},
],
},
{
name: "download",
description: "Download (encrypted) iOS app packages from the App Store",
options: [
bundleIdentifierOption,
{
name: ["-o", "--output"],
description: "The destination path of the downloaded app package",
args: {
name: "output path",
template: "folders",
},
},
{
name: "--purchase",
description: "Obtain a license for the app if needed",
},
],
},
{
name: "help",
description: "Display help for command",
args: { name: "command", isOptional: true, template: "help" },
},
{
name: "purchase",
description: "Obtain a license for the app from the App Store",
options: [bundleIdentifierOption],
},
{
name: "search",
description: "Search for iOS apps available on the App Store",
args: {
name: "query",
},
options: [
{
name: ["-l", "--limit"],
description: "Limit the number of results",
args: {
name: "limit",
default: "5",
},
},
],
},
],
options: [
{
name: ["-h", "--help"],
description: "Show help for ipatool",
isPersistent: true,
},
{
name: "--non-interactive",
description: "Run in non-interactive session",
isPersistent: true,
},
{
name: "--verbose",
description: "Enables verbose logs",
isPersistent: true,
},
{
name: "--format",
description: "Output format",
isPersistent: true,
args: {
name: "format",
suggestions: ["text", "json"],
default: "text",
},
},
{
name: ["-v", "--version"],
description: "Show version for ipatool",
},
],
};
export default completionSpec;