forked from junyiz/dature
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·44 lines (40 loc) · 998 Bytes
/
cli.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
#!/usr/bin/env node
const join = require('path').join
const yargs = require('yargs')
const fetch = require('./lib/fetch')
const package = require('./package.json')
let argv = yargs
.option('u', {
alias : 'uid',
demand: false,
requiresArg: true,
describe: '博客uid',
type: 'string'
})
.option('c', {
alias : 'cookie',
demand: false,
requiresArg: false,
describe: '登录后的cookie',
type: 'string'
})
.usage('Usage: dature [options]')
.help('h')
.alias('h', 'help')
.example('dature -u 1263917762')
.epilog('@junyiz')
.argv;
if (argv.uid) {
console.log(`dature@${package.version}\n`)
const dir = join(process.cwd(), `./blog-${argv.uid}`)
const cookie = (argv.cookie || '')
.replace(/(NowDate|BLOG_TITLE|mblog_userinfo)[^;]*;/g, '')
fetch(dir, argv.uid, cookie).then(function() {
console.info(`\n备份完毕, 博客存储目录:${dir}\n`)
})
} else {
yargs.showHelp()
}
/*
新浪博客UID, 例 1263917762
*/