我正在尝试使用 yargs 验证一些参数,如下所示:
\n\nvar args = require('yargs')\n .command('comando',\n 'comprimenta o usu\xc3\xa1rio', \n function (yargs){\n yargs.options({\n comando: {\n demand: true\n }\n });\n })\n .argv;\nRun Code Online (Sandbox Code Playgroud)\n\n然后我像这样运行我的程序:
\n\nnode app2.js\nRun Code Online (Sandbox Code Playgroud)\n\n或者像这样:
\n\nnode app2.js -comando\nRun Code Online (Sandbox Code Playgroud)\n\n但我没有从程序中收到任何错误消息。我究竟做错了什么?
\n如果您只想提出--comando所需的参数,请尝试以下操作:
var args = require('yargs')\n .command('comando', 'comprimenta o usu\xc3\xa1rio')\n .demand('comando')\n .argv;\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
5344 次 |
| 最近记录: |