1
0
mirror of https://github.com/go-task/task.git synced 2025-06-17 00:17:51 +02:00

feat: suggest the most similar task name when a given task does not exist

This commit is contained in:
Max Pushkarov
2022-10-02 18:49:38 +03:00
parent d2061ec898
commit 3e5ee2332a
7 changed files with 48 additions and 6 deletions

View File

@ -13,11 +13,20 @@ var (
)
type taskNotFoundError struct {
taskName string
taskName string
didYouMean string
}
func (err *taskNotFoundError) Error() string {
return fmt.Sprintf(`task: Task %q not found`, err.taskName)
if err.didYouMean != "" {
return fmt.Sprintf(
`task: Task %q does not exist. Did you mean %q?`,
err.taskName,
err.didYouMean,
)
}
return fmt.Sprintf(`task: Task %q does not exist`, err.taskName)
}
type taskInternalError struct {