Skip to content

Commit 4bdfe64

Browse files
committed
Add hability silent all tasks
By add `silent: true` at the root of the Taskfile.
1 parent ec934ba commit 4bdfe64

File tree

6 files changed

+23
-3
lines changed

6 files changed

+23
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
([#266](https://github.com/go-task/task/pull/266)).
88
- Fixed bug where calling the `task` CLI only informing global vars would not
99
execute the `default` task.
10+
- Add hability to silent all tasks by adding `silent: true` a the root of the
11+
Taskfile.
1012

1113
## v2.7.1 - 2019-11-10
1214

Taskfile.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
version: '2'
22

3+
# silent: true
4+
35
includes:
46
docs: ./docs
57

docs/styleguide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ officially supported. On Linux, only `Taskfile.yml` will work, though.
2828

2929
- `version:`
3030
- `includes:`
31-
- Configuration ones, like `output:` and `expansions:`
31+
- Configuration ones, like `output:`, `expansions:` or `silent:`
3232
- `vars:`
3333
- `env:`
3434
- `tasks:`

docs/usage.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ With silent mode on, the below will be print instead:
674674
Print something
675675
```
676676

677-
There's three ways to enable silent mode:
677+
There are four ways to enable silent mode:
678678

679679
* At command level:
680680

@@ -700,6 +700,19 @@ tasks:
700700
silent: true
701701
```
702702

703+
* Globally at Taskfile level:
704+
705+
```yaml
706+
version: '2'
707+
708+
silent: true
709+
710+
tasks:
711+
echo:
712+
cmds:
713+
- echo "Print something"
714+
```
715+
703716
* Or globally with `--silent` or `-s` flag
704717

705718
If you want to suppress STDOUT instead, just redirect a command to `/dev/null`:

internal/taskfile/taskfile.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type Taskfile struct {
99
Vars Vars
1010
Env Vars
1111
Tasks Tasks
12+
Silent bool
1213
}
1314

1415
// UnmarshalYAML implements yaml.Unmarshaler interface
@@ -26,6 +27,7 @@ func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error {
2627
Vars Vars
2728
Env Vars
2829
Tasks Tasks
30+
Silent bool
2931
}
3032
if err := unmarshal(&taskfile); err != nil {
3133
return err
@@ -37,6 +39,7 @@ func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error {
3739
tf.Vars = taskfile.Vars
3840
tf.Env = taskfile.Env
3941
tf.Tasks = taskfile.Tasks
42+
tf.Silent = taskfile.Silent
4043
if tf.Expansions <= 0 {
4144
tf.Expansions = 2
4245
}

task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func (e *Executor) runCommand(ctx context.Context, t *taskfile.Task, call taskfi
308308
}
309309
return nil
310310
case cmd.Cmd != "":
311-
if e.Verbose || (!cmd.Silent && !t.Silent && !e.Silent) {
311+
if e.Verbose || (!cmd.Silent && !t.Silent && !e.Taskfile.Silent && !e.Silent) {
312312
e.Logger.Errf(cmd.Cmd)
313313
}
314314

0 commit comments

Comments
 (0)