Skip to content

Commit

Permalink
Merge pull request #102 from jcolbyfisher/feature/add-invalid-unmatch…
Browse files Browse the repository at this point in the history
…ed-response

Provide response for zero/unmatched/invalid args
  • Loading branch information
swyxio authored Jan 10, 2019
2 parents 9e73c3d + 68d4ad0 commit fef9efc
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 fef9efc

Please sign in to comment.