Skip to content

Help/usage describes first path only, duplicated, for commands with multiple paths #177

@erictheswift

Description

@erictheswift

When a command has multiple paths and the user types a partial command, the error message shows duplicate suggestions instead of listing all available paths.

Reproduce

cli.register(
  class X extends Command {
    static override paths = [
      ['ls', 'foo'],
      ['ls', 'foos'], 
      ['ls', 'bar'],
      ['ls', 'bars'],
    ]

    async execute() {}
  },
)
$ cli ls
Unknown Syntax Error: Command not found; did you mean one of:

  0. cli ls foo
  1. cli ls foo  
  2. cli ls foo
  3. cli ls foo

While running ls

Also affects --help:

$ cli ls --help
Multiple commands match your selection:
  0. cli ls foo
  1. cli ls foo
  2. cli ls foo
  3. cli ls foo
Run again with -h=<index> to see the longer details of any of those commands.

Expected

Should show all distinct paths:

$ cli ls --help
Multiple commands match your selection:
  0. cli ls foo
  1. cli ls foos
  2. cli ls bar  
  3. cli ls bars
Run again with -h=<index> to see the longer details of any of those commands.

Root Cause

The usage formatter logic appears to be always using the first path, see

segments.push(...this.paths[0]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions