-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Don't Show options when there are no options #689
Comments
The line to change would be here: Probably a change like this: CurrentCommand.prototype.optionHelp = function() {
var width = this.largestOptionLength();
// Append the help information
return this.options.map(function(option) {
return pad(option.flags, width) + ' ' + option.description
+ (option.defaultValue !== undefined ? ' (default: ' + option.defaultValue + ')' : '');
}).concat([pad('-h, --help', width) + ' ' + 'output usage information'])
.join('\n');
}; ProposedCommand.prototype.optionHelp = function() {
if (!this.options.length) return [];
var width = this.largestOptionLength();
// Append the help information
return this.options.map(function(option) {
return pad(option.flags, width) + ' ' + option.description
+ (option.defaultValue !== undefined ? ' (default: ' + option.defaultValue + ')' : '');
}).concat([pad('-h, --help', width) + ' ' + 'output usage information'])
.join('\n');
}; Only join if the array is not empty. |
This has got a few likes and I have thought the same myself at times, so although no recent activity on this issue I am adding a comment rather than closing as stale. A reason for not returning empty If we end up with a parameter for other help behaviours that have been requested, like changing exit behaviour, then there would at least be a place to add a property for suppressing option help as suggested here. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This issue has not had any activity in over six months. Closing in favour of higher level #1225. Feel free to open a new issue if it comes up again, with new information and renewed interest. Thank you for your contributions. |
You can suppress all the options from the help using program
.command('cmd')
.description('a single cmd with no options');
// Hide the options for the top-level help without affecting subcommand help
// by adding configuration after adding the subcommand.
program
.configureHelp({
visibleOptions: () => [],
}); |
The simplest possible executable with a single command and no options still forces showing of options:
yields:
Why show options here? Help is already redundant, and the resulting UI is less usable because the intended call to action obscured by a big in-your-face prompt about
-h
.Can we allow setting a property to now show options?
The text was updated successfully, but these errors were encountered: