mirror of
https://github.com/go-task/task.git
synced 2025-05-13 22:16:31 +02:00
parent
dfd890c8a6
commit
78f6cb08d8
@ -300,6 +300,9 @@ generate-files:
|
|||||||
You can use `--force` or `-f` if you want to force a task to run even when
|
You can use `--force` or `-f` if you want to force a task to run even when
|
||||||
up-to-date.
|
up-to-date.
|
||||||
|
|
||||||
|
Also, `task --status [tasks]...` will exit with non-zero exit code if any of
|
||||||
|
the tasks is not up-to-date.
|
||||||
|
|
||||||
### Variables
|
### Variables
|
||||||
|
|
||||||
When doing interpolation of variables, Task will look for the below.
|
When doing interpolation of variables, Task will look for the below.
|
||||||
|
@ -50,6 +50,7 @@ func main() {
|
|||||||
versionFlag bool
|
versionFlag bool
|
||||||
init bool
|
init bool
|
||||||
list bool
|
list bool
|
||||||
|
status bool
|
||||||
force bool
|
force bool
|
||||||
watch bool
|
watch bool
|
||||||
verbose bool
|
verbose bool
|
||||||
@ -60,6 +61,7 @@ func main() {
|
|||||||
pflag.BoolVar(&versionFlag, "version", false, "show Task version")
|
pflag.BoolVar(&versionFlag, "version", false, "show Task version")
|
||||||
pflag.BoolVarP(&init, "init", "i", false, "creates a new Taskfile.yml in the current folder")
|
pflag.BoolVarP(&init, "init", "i", false, "creates a new Taskfile.yml in the current folder")
|
||||||
pflag.BoolVarP(&list, "list", "l", false, "lists tasks with description of current Taskfile")
|
pflag.BoolVarP(&list, "list", "l", false, "lists tasks with description of current Taskfile")
|
||||||
|
pflag.BoolVar(&status, "status", false, "exits with non-zero exit code if any of the given tasks is not up-to-date")
|
||||||
pflag.BoolVarP(&force, "force", "f", false, "forces execution even when the task is up-to-date")
|
pflag.BoolVarP(&force, "force", "f", false, "forces execution even when the task is up-to-date")
|
||||||
pflag.BoolVarP(&watch, "watch", "w", false, "enables watch of the given task")
|
pflag.BoolVarP(&watch, "watch", "w", false, "enables watch of the given task")
|
||||||
pflag.BoolVarP(&verbose, "verbose", "v", false, "enables verbose mode")
|
pflag.BoolVarP(&verbose, "verbose", "v", false, "enables verbose mode")
|
||||||
@ -116,6 +118,13 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if status {
|
||||||
|
if err = e.Status(calls...); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if err := e.Run(calls...); err != nil {
|
if err := e.Run(calls...); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
18
status.go
18
status.go
@ -8,6 +8,24 @@ import (
|
|||||||
"github.com/go-task/task/internal/status"
|
"github.com/go-task/task/internal/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Status returns an error if any the of given tasks is not up-to-date
|
||||||
|
func (e *Executor) Status(calls ...Call) error {
|
||||||
|
for _, call := range calls {
|
||||||
|
t, ok := e.Tasks[call.Task]
|
||||||
|
if !ok {
|
||||||
|
return &taskNotFoundError{taskName: call.Task}
|
||||||
|
}
|
||||||
|
isUpToDate, err := t.isUpToDate(e.Context)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !isUpToDate {
|
||||||
|
return fmt.Errorf(`task: Task "%s" is not up-to-date`, t.Task)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (t *Task) isUpToDate(ctx context.Context) (bool, error) {
|
func (t *Task) isUpToDate(ctx context.Context) (bool, error) {
|
||||||
if len(t.Status) > 0 {
|
if len(t.Status) > 0 {
|
||||||
return t.isUpToDateStatus(ctx)
|
return t.isUpToDateStatus(ctx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user