Skip to content

Commit

Permalink
added unmatched and invalid args response
Browse files Browse the repository at this point in the history
  • Loading branch information
jcolbyfisher committed Jan 9, 2019
1 parent a273f0e commit 68d4ad0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions bin/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,21 @@ program
});
});

// error on unknown commands
// ref: https://github.com/tj/commander.js#custom-event-listeners
program
.on('command:*', function () {
console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' '));
process.exit(1);
});

program.parse(process.argv);

// check if no command line args are provided
// ref: https://github.com/tj/commander.js/issues/7#issuecomment-32448653
var NO_COMMAND_SPECIFIED = program.args.length === 0;

if (NO_COMMAND_SPECIFIED) {
// user did not supply args, so show --help
program.help();
}

0 comments on commit 68d4ad0

Please sign in to comment.