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

Add support for executable subcommands with help flags differing from those of the parent command #1957

Closed

Conversation

aweebit
Copy link
Contributor

@aweebit aweebit commented Aug 13, 2023

Disclaimer: The change introduced here is of low importance.

This PR builds upon the already approved #1930.

Diff only for the change introduced by this PR:
aweebit/commander.js@feature/fixes...feature/help-command-executable-help-flags

Problem

Currently, help commands don't have support for executable subcommands whose help flags differ from those of the parent command.

Such support could be useful especially when third-party executables are used.

Solution

Get help flags to pass to an executable subcommand from the subcommand instance rather than the parent instance in ._dispatchHelpCommand().

Make it possible to set custom flags for such a subcommand instance by including helpFlags in the options passed to .command().

// program.js
const { Command } = require('commander');

const program = new Command();
program.command('executable', 'description', {
  helpFlags: '-c, --custom-help'
});
program.parse();
// program-executable.js
const { Command } = require('commander');

const program = new Command()
  .helpOption('-c, --custom-help');
program.parse();
node program help executable

ChangeLog

Added

  • support for executable subcommands with help flags differing from those of the parent command (must be specified in the helpFlags option when calling .command())

@shadowspawn shadowspawn added the on hold Not a current focus due to dependencies on other PR or number of other PR label Aug 13, 2023
@aweebit aweebit changed the title Get help flags from subcommand rather than from parent when requested help for an executable subcommand Add support for executable subcommands with help flags differing from those of the parent command Aug 13, 2023
@shadowspawn
Copy link
Collaborator

I like the concept, but so low value and you have so many other PR that closing.

May never come up in the real world!

@shadowspawn shadowspawn removed the on hold Not a current focus due to dependencies on other PR or number of other PR label Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants