getopt.jsx
Synopsis
JSX version of node-getopt.
Code Example
; static : void { var parser = 'o:(output)h(help)' argv; var help = false; var output = ''; var source = : string; var opt = parser; while opt opt = parser; if help || sourcelength == 0 console; else // do some task here console; console; }
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:
$ 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 and
parameter is set to `optarg` (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
- Repository: git://github.com/shibukawa/getopt.jsx.git
- Issues: https://github.com/shibukawa/getopt.jsx.git/issues
Run Test
$ grunt test
Build
# Generate API reference $ grunt doc # Build application or library for JS project $ grunt build
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