task
task copied to clipboard
Proposal: Add templating support for CLI flags list/list-all
This is a proposal (code is finished) adding template support for CLI commands --list / --list-all. The implementation adds an optional flag (--template) which is used to specify a template file(s). When specified, the template files(s) are loaded and rendered. The templating mechanism makes use of slim-sprig functions.
Rational is to allow generation of documentation from Taskfiles, or provide custom formatting for these commands.
fixes #1695 fixes #2261 related #1916 related #931 (perhaps) related #2091
If the proposal is welcome, then at least the following might also be of interest for this PR:
- Documentation with examples.
- Application to the
--summarycommand. - Support template definition in the taskrc file.
- Printing debug info during task execution, using some combination of previous items.
- Additional tests.
- Base templating on JSON data from (i.e.
e.ToEditorOutput()). Perhaps?
Example
mddoc.template
# Taskfile
Available tasks for this project:
{{ range . }}
## {{.Task}}
{{.Desc}}
{{if len .Aliases}}
### Aliases
{{range .Aliases}}- {{.}}
{{end}}{{end}}{{end}}
Console Ouput
$ task --list-all --template mddoc.template
# Taskfile
Available tasks for this project:
## clean
Cleans temp files and folders
### Aliases
- clear
## default
## format
Runs golangci-lint and formats any Go files
### Aliases
- fmt
- f
## generate
Runs all generate tasks
### Aliases
- gen
- g