ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
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 ~~~