Kev*_*vin -1 javascript command-line-arguments node.js command-line-parsing
https://github.com/substack/node-optimist
Optimist是一个node.js库,用于解析那些讨厌选项解析的人的选项.更具体地说,这个模块适用于那些喜欢所有程序使用--bells和-whistlz的人,但认为optstrings是浪费时间.
var argv = require('optimist').argv;
if (argv.rif - 5 * argv.xup > 7.138) {
console.log('Buy more riffiwobbles');
}
else {
console.log('Sell the xupptumblers');
}
Run Code Online (Sandbox Code Playgroud)
rif和xup两个参数.访问命令行参数是一种快速而又脏的方法,而无需在实际使用它们之前在代码中定义它们.示例的第二部分(您在问题中省略)实际上回答了您的第一个问题:
$ ./xup.js --rif=55 --xup=9.52
Buy more riffiwobbles
$ ./xup.js --rif 12 --xup 8.1
Sell the xupptumblers
Run Code Online (Sandbox Code Playgroud)
因此,这些参数在结束了argv.rif和argv.xup.
| 归档时间: |
|
| 查看次数: |
3341 次 |
| 最近记录: |