mirror of
https://github.com/go-task/task.git
synced 2026-06-23 20:55:52 +00:00
chore: improvements on #1163 + changelog entry
This commit is contained in:
@@ -1216,7 +1216,9 @@ tasks:
|
||||
|
||||
Warning Prompts to prompt a user for confirmation before a task is executed.
|
||||
|
||||
Below is an example using `prompt` with a dangerous command, that is called between two safe commands
|
||||
Below is an example using `prompt` with a dangerous command, that is called
|
||||
between two safe commands:
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
@@ -1229,46 +1231,47 @@ tasks:
|
||||
|
||||
not-dangerous:
|
||||
cmds:
|
||||
- echo 'not dangerous command.'
|
||||
- echo 'not dangerous command'
|
||||
|
||||
another-not-dangerous:
|
||||
cmds:
|
||||
- echo 'another not dangerous command.'
|
||||
- echo 'another not dangerous command'
|
||||
|
||||
dangerous:
|
||||
prompt: This is a dangerous command.. Do you want to continue?
|
||||
prompt: This is a dangerous command... Do you want to continue?
|
||||
cmds:
|
||||
- echo 'dangerous command.'
|
||||
|
||||
- echo 'dangerous command'
|
||||
```
|
||||
|
||||
```bash
|
||||
❯ task dangerous
|
||||
task: "This is a dangerous command.. Do you want to continue?" [y/N]
|
||||
task: "This is a dangerous command... Do you want to continue?" [y/N]
|
||||
```
|
||||
|
||||
### Prompt behaviour
|
||||
|
||||
Warning prompts are called before executing a task. If a prompt is denied Task will exit with [Exit code](api_reference.md#exit-codes) 205. If approved, Task will continue as normal.
|
||||
Warning prompts are called before executing a task. If a prompt is denied Task
|
||||
will exit with [exit code](api_reference.md#exit-codes) 205. If approved, Task
|
||||
will continue as normal.
|
||||
|
||||
```bash
|
||||
❯ taskd --dir ./testdata/prompt example
|
||||
task: [not-dangerous] echo 'not dangerous command.'
|
||||
not dangerous command.
|
||||
task: "This is a dangerous command.. Do you want to continue?" [y/N]
|
||||
❯ task example
|
||||
not dangerous command
|
||||
task: "This is a dangerous command. Do you want to continue?" [y/N]
|
||||
y
|
||||
task: [dangerous] echo 'dangerous command.'
|
||||
dangerous command.
|
||||
task: [another-not-dangerous] echo 'another not dangerous command.'
|
||||
another not dangerous command.
|
||||
dangerous command
|
||||
another not dangerous command
|
||||
```
|
||||
|
||||
### Skipping Warning Prompts
|
||||
|
||||
To skip warning prompts automatically, you can use the [-y | --yes] option when calling the task. By including this option, all warnings, will be automatically confirmed, and no prompts will be shows.
|
||||
|
||||
To skip warning prompts automatically, you can use the `--yes` (alias `-y`)
|
||||
option when calling the task. By including this option, all warnings, will be
|
||||
automatically confirmed, and no prompts will be shown.
|
||||
|
||||
:::caution
|
||||
|
||||
Tasks with prompts always fail by default on non-terminal environments, like a
|
||||
CI, where an `stdin` won't be available for the user to answer. In cases like,
|
||||
use `--yes` (`-y`) to force all tasks with a prompt to run.
|
||||
|
||||
:::
|
||||
|
||||
## Silent mode
|
||||
|
||||
|
||||
Reference in New Issue
Block a user