-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathapp.js
53 lines (51 loc) · 1.14 KB
/
app.js
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
#!/usr/bin/env node
const setRequest = require('./request');
const yargs = require('yargs')
.command('photo','Get photos from Tumblr.')
.command('video','Get videos from Tumblr.')
.command('help','Get help information.')
.options({
'username': {
alias: 'u',
default: 'c0096'
},
'page': {
alias: 'p',
default: 0
},
'thread': {
alias: 't',
default: 4,
description: 'Set threads for download.'
},
'output': {
alias: 'o',
description: 'Set output folder.'
},
'noProxy': {
boolean: true,
description: 'Do not use HTTP proxy for download.'
},
'host': {
alias: 'H',
description: 'Set an HTTP proxy host.'
},
'port': {
alias: 'P',
description: 'Set a proxy port.'
},
'timeout': {
alias: 'T',
description: 'Set request timeout.'
}
}).example('$0 photo -u c0096 -p 0')
.example('$0 photo -u slavesmart --port 8080')
.example('$0 video -u c0096 --noProxy')
.demand(['u','p']).argv;
const args = yargs;
args.type = yargs._[0];
if(args.type == 'photo' || args.type == 'video'){
setRequest(args);
}else{
console.error('命令不正确,获取帮助请使用 help 命令')
}