File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ function Parser(stdout) {
7878 this . _version = "0.0.0" ;
7979 this . _epilog = null ;
8080 this . _commands = { } ;
81- this . _default = this . showHelp ;
81+ this . _default = this . showHelp . bind ( this ) ;
8282 this . _width = 0 ;
8383 this . _out = isFunction ( stdout ) ? stdout : console . log ;
8484 this . option ( "help" , "show this help information" , this . showHelp . bind ( this ) ) ;
@@ -178,7 +178,7 @@ Parser.prototype.parse = function(cmds) {
178178 var args = isString ( cmds ) ? cmds . split ( " " ) : processArgv ( ) ;
179179 var context = { } ;
180180 var command = args [ 0 ] ;
181- if ( command === undefined || command [ 0 ] === "-" ) {
181+ if ( command === undefined || command === "" || command [ 0 ] === "-" ) {
182182 context = argv ( args ) ;
183183 context . _option = "default" ;
184184 this . _default . apply ( context , [ ] ) ;
Original file line number Diff line number Diff line change 11{
22 "name" : " simple-argparse" ,
3- "version" : " 0.2.1 " ,
3+ "version" : " 0.2.2 " ,
44 "description" : " Simple Argument parser for Command-line Applications" ,
5- "homepage" : " https://github.com/forfuture-dev /node-simple-argparse" ,
5+ "homepage" : " https://github.com/forfutureLLC /node-simple-argparse" ,
66 "license" : " MIT" ,
77 "repository" : {
88 "type" : " git" ,
2121 "author" : " GochoMugo <mugo@forfuture.co.ke>" ,
2222 "main" : " index.js" ,
2323 "dependencies" : {
24- "minimist" : " ^1.1.1 "
24+ "minimist" : " ^1.1.2 "
2525 },
2626 "devDependencies" : {
2727 "coveralls" : " ^2.11.3" ,
Original file line number Diff line number Diff line change @@ -202,6 +202,14 @@ describe("Parser", function() {
202202 } ) ;
203203 parser . showHelp ( ) ;
204204 } ) ;
205+
206+ it ( "show help information as the default option" , function ( done ) {
207+ new Parser ( function ( out ) {
208+ out . should . containEql ( "just simple" ) ;
209+ done ( ) ;
210+ } ) . option ( "simple" , "just simple" , function ( ) { } )
211+ . parse ( "" ) ;
212+ } ) ;
205213} ) ;
206214
207215
You can’t perform that action at this time.
0 commit comments