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

@@ -44,7 +44,7 @@ If `--` is given, all remaning arguments will be assigned to a special
| | `--output-group-error-only` | `bool` | `false` | Swallow command output on zero exit code. |
| `-p` | `--parallel` | `bool` | `false` | Executes tasks provided on command line in parallel. |
| `-s` | `--silent` | `bool` | `false` | Disables echoing. |
| `-y` | `--yes` | `bool` | `false` | Assume "yes" as answer to all prompts. |
| `-y` | `--yes` | `bool` | `false` | Assume "yes" as answer to all prompts. |
| | `--status` | `bool` | `false` | Exits with non-zero exit code if any of the given tasks is not up-to-date. |
| | `--summary` | `bool` | `false` | Show summary about a task. |
| `-t` | `--taskfile` | `string` | `Taskfile.yml` or `Taskfile.yaml` | |

View File

@@ -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