项目作者: watsonserve

项目描述 :
Parse command line arguments for the UNIX style
高级语言: JavaScript
项目地址: git://github.com/watsonserve/optionJS.git
创建时间: 2017-07-01T08:10:59Z
项目社区:https://github.com/watsonserve/optionJS

开源协议:GNU Lesser General Public License v3.0

下载


opt-arguments

Parse command line arguments for the UNIX style

use:

  1. optArguments([{
  2. opt: String, // a char to short option, like -x
  3. option: String, // a word to long option, like --xxxx=yyyy
  4. }, ...])

example

in test.js:

  1. const optArguments = require('opt-arguments');
  2. let arguments = optArguments([{
  3. opt: 'h',
  4. option: 'help'
  5. }, {
  6. opt: 'o',
  7. option: 'out'
  8. }]);
  9. console.log(JSON.stringify(arguments));

shell:

node test.js -o obj.o src.src or node test.js --out=obj.o src.src

console:

  1. {
  2. "options": {
  3. "out": "obj.o"
  4. },
  5. "default": ["src.src"]
  6. }