Skip to content

Instantly share code, notes, and snippets.

@magicdawn
Last active July 19, 2017 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magicdawn/159a475d94f329d890cb0f8ae28fb52d to your computer and use it in GitHub Desktop.
Save magicdawn/159a475d94f329d890cb0f8ae28fb52d to your computer and use it in GitHub Desktop.
yargs
const i = yargs
.usage('$0 -u <url> [options]')
.option('url', {
alias: 'u',
describe: '专辑/歌单 url',
required: true,
type: 'string',
})
.option('concurrency', {
alias: 'c',
describe: '设置同时下载数量',
default: 5,
type: 'number',
})
.option('format', {
alias: 'f',
describe: '设置文件格式',
default: ':name/:singer - :songName.:ext',
})
.choices('quality', [128, 192, 320])
.option('quality', {
alias: 'q',
describe: '设置音质',
default: 320,
})
.coerce('quality', num => num * 1000)
.option('max-times', {
describe: '设置下载重试次数',
default: 5,
type: 'number',
})
.option('timeout', {
describe: '设置下载超时(分)',
default: 3,
type: 'number',
})
.coerce('timeout', num => num * 60 * 1000) // to ms
.example(
'10首同时下载',
'yun -c 10 -u http://music.163.com/#/playlist?id=12583200'
)
.example(
`下载格式为 '歌手 - 歌名'`,
`yun -f ':singer - :songName.:ext' -u http://music.163.com/#/playlist?id=12583200`
)
.epilog('Homepage: http://github.com/magicdawn/yun-playlist-downloader')
.version(pkgVersion)
.help(true)
const argv = i.argv
console.log(argv)
@magicdawn
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment