Skip to content

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

@mitsukuri

Description

@mitsukuri

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugCommander is not working as intended

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions