Skip to content

Suggest similar command names when the requested tool is not found #404

Description

@cschanhniem

Feature Request

When a user mistypes a command name, halp currently returns no useful output because all help flags fail against the non-existent binary. This is a common UX friction point — CLI tools with many subcommands (git, cargo, docker, npm) are especially prone to typos.

Proposed behavior

When halp <cmd> fails to find the command (all help/version checks return non-zero because the binary doesn't exist), halp could fall back to searching PATH for similarly named commands and suggest them:

$ halp gti
"gti" not found. Did you mean one of these?
  git  — the stupid content tracker
  gtime — timed execution of commands

Implementation sketch

  1. After all help/version probes fail, collect the exit codes
  2. If the exit codes suggest the binary itself wasn't found (e.g., Command returned NotFound), walk PATH entries
  3. Compute Levenshtein or Jaro-Winkler distance between the requested command and each PATH entry
  4. Return the top 3-5 closest matches with their short descriptions (from --version or whatis)

Prior art

  • git has git help -a and suggests similar commands on typos
  • apt suggests "did you mean" for misspelled package names
  • cargo suggests similar subcommands
  • The thefuck tool corrects previous console commands

Why this fits halp

Halp is already positioned as the "help with CLI tools" tool. Making it resilient to typos adds a concrete new capability — instead of just checking flags for known tools, it helps users discover the right tool name in the first place.

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