arcanis/clipanion

When multiple commands with common prefix are registered, calling `--help` with the prefix should list them all

Closed this issue · 2 comments

Context

Consider this code:

const { Command } = require('clipanion');

class TypecheckCommand extends Command {
    static paths = [['typecheck']];
    ...
}

class TypecheckStopCommand extends Command {
    static paths = [['typecheck', 'stop']];
    ...
}

module.exports = [TypecheckCommand, TypecheckStopCommand];

Current behavior

yarn cli typecheck --help prints only info about typecheck itself.

Expected behavior

It should at least indicate the existence of the other subcommands (in this case yarn cli typecheck stop).

In the same vein, I think that with this code:

const { Command } = require('clipanion');

class TypecheckStartCommand extends Command {
    static paths = [['typecheck', 'start']]; // I know it doesn't make sense, but that's for the example
    ...
}

class TypecheckStopCommand extends Command {
    static paths = [['typecheck', 'stop']];
    ...
}

module.exports = [TypecheckStartCommand, TypecheckStopCommand];

The output should not show:

Unknown Syntax Error: Command not found; did you mean one of:

  1. yarn cli typecheck start
  2. yarn cli typecheck stop

While running cli typecheck --help

But rather exactly the same output as the built-in --help, but just filtered out.

What do you think @arcanis?

I can work on a PR if you accept the suggestion.