npm install getopt.jsxgetopt.jsx
===========================================

Synopsis
---------------
JSX version of node-getopt.
Code Example
---------------
``js
import "getopt.jsx";
class _Main {
static function main(argv : string[]) : void
{
var parser = new BasicParser('o:(output)h(help)', argv);
var help = false;
var output = '';
var source = [] : string[];
var opt = parser.getopt();
while (opt)
{
switch (opt.option)
{
case 'o':
output = opt.optarg;
break;
case 'h':
help = true;
break;
default:
source.push(opt.option);
break;
}
opt = parser.getopt();
}
if (help || source.length == 0)
{
console.log('''
$ getopt-sample [options] source...
options:
-o file, --output=file : set output file
-h, --help : show this message
''');
}
else
{
// do some task here
console.log("source:", source.join(', '));
console.log("output:", output);
}
}
}
`
Motivation
---------------
It provides command line parsing feature to your cool JSX program.
Installation
---------------
If you want to use this library from other project, install like the following:
`sh`
$ npm install getopt.jsx --save-dev
API Reference
------------------
class BasicParser(opt : string, argv : string[])
It receives command pattern as first parameter and actual options as second parameter.
BasicParser.getopt() : CommandOption
It returns analysing parameter. If it consumes all parameters, it returns null.
class CommandOption
it has option, optarg parameter. If argument has parameter, option is a short name of command andoptarg
parameter is set to (see case sentenses of the above sample).
If needed parameter is not provided, error flag become true.
Extra arguments are set to option (see default block of the above sample).
Option Pattern
-------------------
s(long)
it become flag option (no parameter). BasicParser can accept -s and --long.
s:(long)
it become flag option with parameter. BasicParser can accept -s option and --long=option.
Development
-------------
* Repository: git://github.com/shibukawa/getopt.jsx.git
* Issues: https://github.com/shibukawa/getopt.jsx.git/issues
`sh`
$ grunt test
`shGenerate API reference
$ grunt doc
Author
---------
* shibukawa / yoshiki@shibu.jp
License
------------
MIT
Complete license is written in
LICENSE.md`.Original Version
---------------------
* Author: David Pacheco
* github: https://github.com/davepacheco/node-getopt
* License: MIT