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

.helpOption(false) also disables subcommand help command #1863

Closed
mitsukuri opened this issue Apr 15, 2023 · 2 comments
Closed

.helpOption(false) also disables subcommand help command #1863

mitsukuri opened this issue Apr 15, 2023 · 2 comments
Labels
bug Commander is not working as intended

Comments

@mitsukuri
Copy link

mitsukuri commented Apr 15, 2023

In this example, I'd like to disable impilcit help option and only leave impicit help command.
test.mjs:

#!/usr/bin/env node
import { Command } from 'commander';
const cmd = new Command ();
cmd
   .helpOption (false)
   .command ('meow')
   .option ('-l, [--loud]')

cmd.parse ();

If I run test.mjs, I get

Usage: test [command]

Commands:
  meow [options]
  help [command]  display help for command

as expected, but if I run test.mjs help meow, I get an error:

error: unknown option '--help' // what option, I thought I was calling help command?,

while expected outcome would be

Usage: test meow [options]

Options:
  -l, [--loud]
@mitsukuri mitsukuri changed the title .helpOption also disables subcommand help command .helpOption(false) also disables subcommand help command Apr 15, 2023
@shadowspawn
Copy link
Collaborator

You have found a shortcoming in the help support!

The help command is implemented by passing --help into the subcommand. It was done this way so it could also work with stand-alone external subcommands.

I think it would be reasonable to call directly into the help for a known (non-external) command. This would make the support more robust.

@shadowspawn shadowspawn added the bug Commander is not working as intended label Apr 15, 2023
@shadowspawn shadowspawn added the pending release Merged into a branch for a future release, but not released yet label Apr 21, 2023
@shadowspawn shadowspawn removed the pending release Merged into a branch for a future release, but not released yet label Jun 16, 2023
@shadowspawn
Copy link
Collaborator

This is fixed in v11

Thanks @mitsukuri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Commander is not working as intended
Projects
None yet
Development

No branches or pull requests

2 participants