commander / 2.4.0 last updated 22 days ago created on Aug 14th 2011
Install
npm install --save commander
Clone
git clone git@github.com:visionmedia/commander.js.git
dependencies
No dependencies listed.
maintainers
versions
24 total
| 2.4.0 | 22 days ago | zhiyelee |
| 2.3.0 | 4 months ago | somekittens |
| 2.2.0 | 7 months ago | tjholowaychuk |
| 2.1.0 | a year ago | tjholowaychuk |
| 2.0.0 | a year ago | tjholowaychuk |
| 1.3.2 | a year ago | tjholowaychuk |
| 1.3.1 | a year ago | tjholowaychuk |
| 1.3.0 | a year ago | tjholowaychuk |
| 1.2.0 | a year ago | tjholowaychuk |
| 1.1.1 | 2 years ago | tjholowaychuk |
| 1.1.0 | 2 years ago | tjholowaychuk |
| 1.0.5 | 2 years ago | tjholowaychuk |
| 0.6.1 | 2 years ago | tjholowaychuk |
| 0.6.0 | 3 years ago | tjholowaychuk |
| 0.5.1 | 3 years ago | tjholowaychuk |
| 0.5.0 | 3 years ago | tjholowaychuk |
| 0.4.3 | 3 years ago | tjholowaychuk |
| 0.4.2 | 3 years ago | tjholowaychuk |
| 0.4.1 | 3 years ago | tjholowaychuk |
| 0.4.0 | 3 years ago | tjholowaychuk |
| 0.3.3 | 3 years ago | tjholowaychuk |
| 0.3.2 | 3 years ago | tjholowaychuk |
| 0.3.1 | 3 years ago | tjholowaychuk |
| 0.3.0 | 3 years ago | tjholowaychuk |
readme
Commander.js
The complete solution for node.js command-line interfaces, inspired by Ruby's commander.
Installation
Option parsing
Options with commander are defined with the .option() method, also serving as documentation for the options. The example below parses args and options from process.argv, leaving remaining args as the program.args array which were not consumed by options.
Short flags may be passed as a single arg, for example -abc is equivalent to -a -b -c. Multi-word options such as "--template-engine" are camel-cased, becoming program.templateEngine etc.
Automated --help
The help information is auto-generated based on the information commander already knows about your program, so the following --help info is for free:
Coercion
Custom help
You can display arbitrary -h, --help information
by listening for "--help". Commander will automatically
exit once you are done so that the remainder of your program
does not execute causing undesired behaviours, for example
in the following executable "stuff" will not output when
--help is used.
yielding the following help output:
.outputHelp()
Output help information without exiting.
.help()
Output help information and exit immediately.
Links
License
(The MIT License)
Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.