Skip to content

fix: show error message and suggestions for unknown subcommands#121

Merged
avihut merged 2 commits intomasterfrom
daft-110/unknown-cmd-error
Jan 31, 2026
Merged

fix: show error message and suggestions for unknown subcommands#121
avihut merged 2 commits intomasterfrom
daft-110/unknown-cmd-error

Conversation

@avihut
Copy link
Owner

@avihut avihut commented Jan 31, 2026

Summary

  • Unknown subcommands (daft foo, git daft foo) now print a clear error to stderr and exit with code 1, instead of silently showing help and exiting with code 0
  • Includes Levenshtein distance-based "did you mean?" suggestions that mirror git's own error format (e.g., daft steup suggests setup)
  • daft and git-daft with no arguments continue to show help and exit with code 0

Test plan

  • cargo fmt -- --check passes
  • cargo clippy -- -D warnings passes
  • cargo test --lib — 135 unit tests pass (15 new tests for suggest module)
  • just test-integration-unknown-command — 6 integration tests pass
  • Manual verification of daft nonexistent, daft steup, daft (no args), git-daft foo, git-daft (no args)

Fixes #110

🤖 Generated with Claude Code

When a user types an unknown subcommand (e.g., `daft foo` or `git daft foo`),
the binary now prints a clear error message to stderr and exits with code 1,
instead of silently showing the full help text and exiting with code 0.

Includes Levenshtein distance-based "did you mean?" suggestions that mirror
git's own error format.

Fixes #110

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@avihut avihut self-assigned this Jan 31, 2026
@avihut avihut added bug Something isn't working fix Bug fix labels Jan 31, 2026
@avihut avihut added this to the v1.1.0 milestone Jan 31, 2026
The unknown subcommand handler was catching --help and -h flags for
both `daft` and `git-daft`, treating them as unknown commands. Add
explicit match arms for these flags to route to docs::run() instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@avihut avihut merged commit 15e481a into master Jan 31, 2026
5 checks passed
@avihut avihut deleted the daft-110/unknown-cmd-error branch January 31, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typing a wrong daft command just prints help but doesn't indicate error

1 participant