mirror of
https://github.com/go-task/task.git
synced 2025-06-15 00:15:10 +02:00
Add hability silent all tasks
By add `silent: true` at the root of the Taskfile.
This commit is contained in:
@ -7,6 +7,8 @@
|
|||||||
([#266](https://github.com/go-task/task/pull/266)).
|
([#266](https://github.com/go-task/task/pull/266)).
|
||||||
- Fixed bug where calling the `task` CLI only informing global vars would not
|
- Fixed bug where calling the `task` CLI only informing global vars would not
|
||||||
execute the `default` task.
|
execute the `default` task.
|
||||||
|
- Add hability to silent all tasks by adding `silent: true` a the root of the
|
||||||
|
Taskfile.
|
||||||
|
|
||||||
## v2.7.1 - 2019-11-10
|
## v2.7.1 - 2019-11-10
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
version: '2'
|
version: '2'
|
||||||
|
|
||||||
|
# silent: true
|
||||||
|
|
||||||
includes:
|
includes:
|
||||||
docs: ./docs
|
docs: ./docs
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ officially supported. On Linux, only `Taskfile.yml` will work, though.
|
|||||||
|
|
||||||
- `version:`
|
- `version:`
|
||||||
- `includes:`
|
- `includes:`
|
||||||
- Configuration ones, like `output:` and `expansions:`
|
- Configuration ones, like `output:`, `expansions:` or `silent:`
|
||||||
- `vars:`
|
- `vars:`
|
||||||
- `env:`
|
- `env:`
|
||||||
- `tasks:`
|
- `tasks:`
|
||||||
|
@ -674,7 +674,7 @@ With silent mode on, the below will be print instead:
|
|||||||
Print something
|
Print something
|
||||||
```
|
```
|
||||||
|
|
||||||
There's three ways to enable silent mode:
|
There are four ways to enable silent mode:
|
||||||
|
|
||||||
* At command level:
|
* At command level:
|
||||||
|
|
||||||
@ -700,6 +700,19 @@ tasks:
|
|||||||
silent: true
|
silent: true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* Globally at Taskfile level:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
version: '2'
|
||||||
|
|
||||||
|
silent: true
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
echo:
|
||||||
|
cmds:
|
||||||
|
- echo "Print something"
|
||||||
|
```
|
||||||
|
|
||||||
* Or globally with `--silent` or `-s` flag
|
* Or globally with `--silent` or `-s` flag
|
||||||
|
|
||||||
If you want to suppress STDOUT instead, just redirect a command to `/dev/null`:
|
If you want to suppress STDOUT instead, just redirect a command to `/dev/null`:
|
||||||
|
@ -9,6 +9,7 @@ type Taskfile struct {
|
|||||||
Vars Vars
|
Vars Vars
|
||||||
Env Vars
|
Env Vars
|
||||||
Tasks Tasks
|
Tasks Tasks
|
||||||
|
Silent bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalYAML implements yaml.Unmarshaler interface
|
// UnmarshalYAML implements yaml.Unmarshaler interface
|
||||||
@ -26,6 +27,7 @@ func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
Vars Vars
|
Vars Vars
|
||||||
Env Vars
|
Env Vars
|
||||||
Tasks Tasks
|
Tasks Tasks
|
||||||
|
Silent bool
|
||||||
}
|
}
|
||||||
if err := unmarshal(&taskfile); err != nil {
|
if err := unmarshal(&taskfile); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -37,6 +39,7 @@ func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
tf.Vars = taskfile.Vars
|
tf.Vars = taskfile.Vars
|
||||||
tf.Env = taskfile.Env
|
tf.Env = taskfile.Env
|
||||||
tf.Tasks = taskfile.Tasks
|
tf.Tasks = taskfile.Tasks
|
||||||
|
tf.Silent = taskfile.Silent
|
||||||
if tf.Expansions <= 0 {
|
if tf.Expansions <= 0 {
|
||||||
tf.Expansions = 2
|
tf.Expansions = 2
|
||||||
}
|
}
|
||||||
|
2
task.go
2
task.go
@ -308,7 +308,7 @@ func (e *Executor) runCommand(ctx context.Context, t *taskfile.Task, call taskfi
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
case cmd.Cmd != "":
|
case cmd.Cmd != "":
|
||||||
if e.Verbose || (!cmd.Silent && !t.Silent && !e.Silent) {
|
if e.Verbose || (!cmd.Silent && !t.Silent && !e.Taskfile.Silent && !e.Silent) {
|
||||||
e.Logger.Errf(cmd.Cmd)
|
e.Logger.Errf(cmd.Cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user