多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
yargs 模块提供以下方法,生成帮助信息。 > * usage:用法格式 > * example:提供例子 > * help:显示帮助信息 > * epilog:出现在帮助信息的结尾 ~~~ #!/usr/bin/env node var argv = require('yargs') .option('f', { alias : 'name', demand: true, default: 'tom', describe: 'your name', type: 'string' }) .usage('Usage: hello [options]') .example('hello -n tom', 'say hello to Tom') .help('h') .alias('h', 'help') .epilog('copyright 2015') .argv; console.log('hello ', argv.n); ~~~ 执行结果如下。 ~~~ $ hello -h Usage: hello [options] Options: -f, --name your name [string] [required] [default: "tom"] -h, --help Show help [boolean] Examples: hello -n tom say hello to Tom copyright 2015 ~~~