Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolves #766 suggest to users run --help command #771

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ Command.prototype.opts = function() {
Command.prototype.missingArgument = function(name) {
console.error();
console.error(" error: missing required argument `%s'", name);
console.error(" Try '--help' for more information.");
console.error();
process.exit(1);
};
Expand All @@ -806,6 +807,7 @@ Command.prototype.optionMissingArgument = function(option, flag) {
} else {
console.error(" error: option `%s' argument missing", option.flags);
}
console.error(" Try '--help' for more information.");
console.error();
process.exit(1);
};
Expand All @@ -821,6 +823,7 @@ Command.prototype.unknownOption = function(flag) {
if (this._allowUnknownOption) return;
console.error();
console.error(" error: unknown option `%s'", flag);
console.error(" Try '--help' for more information.");
console.error();
process.exit(1);
};
Expand All @@ -835,6 +838,7 @@ Command.prototype.unknownOption = function(flag) {
Command.prototype.variadicArgNotLast = function(name) {
console.error();
console.error(" error: variadic arguments must be last `%s'", name);
console.error(" Try '--help' for more information.");
console.error();
process.exit(1);
};
Expand Down
4 changes: 2 additions & 2 deletions test/test.command.allowUnknownOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ program
.option('-p, --pepper', 'add pepper');
program.parse('node test -m'.split(' '));

stubError.callCount.should.equal(3);
stubError.callCount.should.equal(4);


// test subcommand
Expand All @@ -24,7 +24,7 @@ program
});
program.parse('node test sub -m'.split(' '));

stubError.callCount.should.equal(3);
stubError.callCount.should.equal(4);
stubExit.calledOnce.should.be.true();

// command with `allowUnknownOption`
Expand Down
2 changes: 1 addition & 1 deletion test/test.options.args.required.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ console.error = function () {

process.on('exit', function (code) {
code.should.equal(1);
info.length.should.equal(3);
info.length.should.equal(4);
info[1].should.equal(" error: option `-c, --cheese <type>' argument missing");
process.exit(0)
});
Expand Down
1 change: 1 addition & 0 deletions test/test.variadic.args.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ console.error = oldConsoleError;
[
'',
' error: variadic arguments must be last `variadicArg\'',
' Try \'--help\' for more information.',
''
].join('\n').should.eql(errorMessage);