1
0
mirror of https://github.com/go-task/task.git synced 2025-11-23 22:24:45 +02:00

chore: improvements on #1163 + changelog entry

This commit is contained in:
Andrey Nering
2023-06-03 22:33:22 -03:00
parent f815ce2901
commit 44aaec86a1
9 changed files with 80 additions and 41 deletions

View File

@@ -99,18 +99,34 @@ func (err *TaskCalledTooManyTimesError) Code() int {
return CodeTaskCalledTooManyTimes
}
// TaskCancelledError is returned when the user does not accept an optional prompt to continue.
type TaskCancelledError struct {
// TaskCancelledByUserError is returned when the user does not accept an optional prompt to continue.
type TaskCancelledByUserError struct {
TaskName string
}
func (err *TaskCancelledError) Error() string {
func (err *TaskCancelledByUserError) Error() string {
return fmt.Sprintf(
`task: %q Cancelled by user`,
`task: Task "%q" cancelled by user`,
err.TaskName,
)
}
func (err *TaskCancelledError) Code() int {
func (err *TaskCancelledByUserError) Code() int {
return CodeTaskCancelled
}
// TaskCancelledNoTerminalError is returned when trying to run a task with a prompt in a non-terminal environment.
type TaskCancelledNoTerminalError struct {
TaskName string
}
func (err *TaskCancelledNoTerminalError) Error() string {
return fmt.Sprintf(
`task: Task "%q" cancelled because it has a prompt and the environment is not a terminal. Use --yes (-y) to run anyway.`,
err.TaskName,
)
}
func (err *TaskCancelledNoTerminalError) Code() int {
return CodeTaskCancelled
}