Skip to content

Typo suggestion prints "Did you mean ''?" when no command is close #2

Description

@pranav-dp

hey.. found a small bug when i was trying out the CLI..

when u type a command thats close to a real keyword, it gives a good suggestion like :

  $ context-dev brnd
  No help topic for 'brnd'. Did you mean 'context-dev brand'?

but when the command is not close to anything, the suggestion comes out empty:

  $ context-dev qqqq
  No help topic for 'qqqq'. Did you mean ''?

so it shows "Did you mean ''?" with nothing inside the quotes.

i think the cause is in pkg/cmd/suggest.go: suggestCommand always returns a
"Did you mean '...'?" string, even when it didnt find a close match. the
original urfave/cli version returns an empty string in that case, and the
caller only prints a suggestion when its not empty - so here the empty one
slips through.

happy to send a small PR for this if its useful - basically return an empty
string when nothing's close, so it just stays quiet. real typos like 'brnd'
would keep working.

side thought (separate from the bug, feel free to ignore): when nothing is
close, instead of showing nothing, maybe it could nudge people toward the
command list? something like:

  No help topic for 'qqqq'. Run 'context-dev --help' to see available commands.

or if a couple of commands are actually similar, just list those few. not sure
if that fits the direction u want - happy to help either way

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions