Skip to content

Commit 1ffe17a

Browse files
committed
update cli flags and structure
1 parent 51600f7 commit 1ffe17a

File tree

1 file changed

+82
-50
lines changed

1 file changed

+82
-50
lines changed

src/cli.ts

Lines changed: 82 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function getOptions(args, logger) {
4040
logger,
4141
plugins: [],
4242
silent: args["silent"],
43-
sleepTime: 2,
43+
sleepTime: args["sleep"],
4444
strict: args["strict"],
4545
total: args["count"],
4646
};
@@ -152,117 +152,149 @@ function buildParser(args, callback) {
152152
.options({
153153
count: {
154154
alias: "c",
155+
number: true,
155156
default: 0,
156-
describe: "Number of posts to download. 0 to download all",
157+
describe: "Number of posts to download (0 for all)",
158+
group: "Configuration",
157159
},
158-
visible: {
160+
full: {
161+
alias: ["f"],
159162
boolean: true,
160163
default: false,
161-
describe: "Show browser on the screen",
164+
describe: "Retrieve full post data",
165+
group: "Configuration",
162166
},
163-
download: {
164-
alias: "d",
165-
boolean: true,
166-
default: false,
167-
describe: "Save images and videos from posts",
167+
sleep: {
168+
alias: ["s"],
169+
number: true,
170+
default: 2,
171+
describe: "Seconds to sleep between interactions",
172+
group: "Configuration",
168173
},
169174
graft: {
170175
alias: "g",
171176
boolean: true,
172177
default: true,
173178
describe: "Enable grafting",
179+
group: "Configuration",
174180
},
175-
full: {
176-
boolean: true,
177-
default: false,
178-
describe:
179-
"Get the full list of posts and their details from the API and web page",
181+
browser: {
182+
alias: ["b"],
183+
string: true,
184+
default: undefined,
185+
describe: "Browser path. Defaults to the puppeteer version",
186+
group: "Configuration",
180187
},
181-
video: {
188+
download: {
189+
alias: "d",
182190
boolean: true,
183191
default: false,
184-
describe: "Download videos. Only works in full mode",
192+
describe: "Save images from posts",
193+
group: "Download",
185194
},
186-
silent: {
187-
boolean: true,
188-
default: false,
189-
describe: "Disable progress output",
195+
downdir: {
196+
default: "downloads/[endpoint]/[id]",
197+
describe: "Download path",
198+
group: "Download",
190199
},
191-
strict: {
200+
video: {
201+
alias: "v",
192202
boolean: true,
193203
default: false,
194-
describe:
195-
"Throw an error if types from Instagram API have been changed",
204+
describe: "Download videos (requires full)",
205+
implies: "full",
206+
group: "Download",
207+
},
208+
upload: {
209+
alias: ["u"],
210+
string: true,
211+
default: undefined,
212+
describe: "Upload files to a URL with a PUT request",
213+
group: "Download",
196214
},
197215
sync: {
198216
boolean: true,
199217
default: false,
200-
describe: "Synchronously download files between API requests",
218+
describe: "Force download between requests",
219+
group: "Download",
201220
},
202221
threads: {
203222
alias: "k",
204223
number: true,
205224
default: 4,
206-
describe: "The number of parallel download / upload threads",
225+
describe: "Parallel download / upload threads",
226+
group: "Download",
207227
},
208228
waitDownload: {
209229
alias: "w",
210230
boolean: true,
211231
default: false,
212-
describe:
213-
"When true, media will only download once scraping is finished",
232+
describe: "Download media after scraping",
233+
group: "Download",
214234
},
215235
filename: {
216-
alias: ["file", "f"],
236+
alias: ["file", "o"],
237+
string: true,
217238
default: "[id]",
218239
describe: "Name of the output file",
240+
group: "Output",
219241
},
220242
filetype: {
221243
alias: ["type", "t"],
222244
default: "json",
223245
choices: ["csv", "json", "both"],
224-
describe: "Type of output file ",
225-
},
226-
downdir: {
227-
default: "downloads/[endpoint]/[id]",
228-
describe: "Directory / Container to save media",
246+
group: "Output",
229247
},
230248
mediaPath: {
231-
alias: "mp",
249+
alias: ["m"],
232250
boolean: true,
233251
default: false,
234-
describe:
235-
"Store the paths of downloaded media in the '_mediaPath' key",
252+
describe: "Add filepaths to _mediaPath",
253+
group: "Output",
254+
},
255+
visible: {
256+
boolean: true,
257+
default: false,
258+
describe: "Show browser on the screen",
259+
group: "Display",
260+
},
261+
quiet: {
262+
alias: ["q"],
263+
boolean: true,
264+
default: false,
265+
describe: "Disable progress output",
266+
group: "Display",
236267
},
237268
logging: {
269+
alias: ["l"],
238270
default: "none",
239-
choices: ["error", "none", "info", "debug"],
240-
describe: "Level of logger",
271+
choices: ["none", "error", "info", "debug"],
272+
group: "Logging",
241273
},
242274
logfile: {
275+
string: true,
243276
default: "instamancer.log",
244-
describe: "Name of the log file",
245-
},
246-
browser: {
247-
default: undefined,
248-
describe:
249-
"Location of the browser. Defaults to the copy downloaded at installation",
277+
describe: "Log file name",
278+
group: "Logging",
250279
},
251-
upload: {
252-
default: undefined,
253-
describe:
254-
"Upload files to a URL with a PUT request rather than saving to disk",
280+
strict: {
281+
boolean: true,
282+
default: false,
283+
describe: "Throw an error on response type mismatch",
284+
group: "Validation",
255285
},
256286
plugin: {
287+
alias: ["p"],
257288
array: true,
258289
default: [],
259290
describe: "Use a plugin from the plugins directory",
291+
group: "Plugins",
260292
},
261293
})
262294
.demandCommand()
263295
.example(
264-
"$0 hashtag instagood -d",
265-
"Download all the available posts, and their thumbnails from #instagood",
296+
"$0 hashtag instagood -fvd",
297+
"Download all the available posts, and their media from #instagood",
266298
)
267299
.example(
268300
"$0 user arianagrande --filetype=csv --logging=info --visible",

0 commit comments

Comments
 (0)