task icon indicating copy to clipboard operation
task copied to clipboard

Allow `status:` to run other tasks

Open dolfelt opened this issue 4 years ago • 4 comments

When writing many commands we have a standard way of checking status for each. It would be nice to be able to write a task and use another task to check the status. For example:

tasks:
  make:
    status:
      - task: check-file
        vars: { FILE: path/to/file.exe }
    cmds:
      - do command

From what I can tell Status is just an []string rather than an []*Cmd. https://github.com/go-task/task/blob/master/taskfile/task.go#L16

Thoughts on updating it to work more like cmds? What potential pitfalls might occur?

Thanks!

dolfelt avatar Jun 29 '21 21:06 dolfelt

Hi @dolfelt!

I think that this seems to make sense to have.

Changing Status from []string to []*Cmd is the initial step, but more changes will be needed to make it work.

andreynering avatar Jul 11 '21 01:07 andreynering

+1 on this feature!

A possibly related question. Would having this feature result in being able to reference a variable in status: that is defined in the vars: of the same task?

ivotron avatar Nov 19 '21 01:11 ivotron

...being able to reference a variable in status: that is defined in the vars: of the same task?

err... please ignore the above comment, i just realized i was doing something wrong when testing this. it is possible to use a variable used in vars: in status:. sorry for the noise!

ivotron avatar Nov 19 '21 01:11 ivotron

I think this is possibly similar to #178 basically, the ability to use tasks (or vars for that matter) kind of like functions. Thus supporting return values, and being to use tasks in other areas, like status. This is interesting, and I want to explore this type of functionality.

ghostsquad avatar Apr 29 '22 05:04 ghostsquad