mirror of
https://github.com/go-task/task.git
synced 2025-08-10 22:42:19 +02:00
Add CHANGELOG, documentation and small improvements to #401
This commit is contained in:
@@ -2,9 +2,13 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- A new `--list-all` (alias `-a`) flag is now available. It's similar to the
|
||||
exiting `--list` (`-l`) but prints all tasks, even those without a
|
||||
description
|
||||
([#383](https://github.com/go-task/task/issues/383), [#401](https://github.com/go-task/task/pull/401)).
|
||||
- It's now possible to schedule cleanup commands to run once a task finishes
|
||||
with the `defer:` keyword
|
||||
([Documentation](https://taskfile.dev/#/usage?id=doing-task-cleanup-with-defer), [#475](https://github.com/go-task/task/issues/475), [#626](https://github.com/go-task/task/pull/626/files)).
|
||||
([Documentation](https://taskfile.dev/#/usage?id=doing-task-cleanup-with-defer), [#475](https://github.com/go-task/task/issues/475), [#626](https://github.com/go-task/task/pull/626)).
|
||||
- Remove long deprecated and undocumented `$` variable prefix and `^` command
|
||||
prefix
|
||||
([#642](https://github.com/go-task/task/issues/642), [#644](https://github.com/go-task/task/issues/644), [#645](https://github.com/go-task/task/pull/645)).
|
||||
|
@@ -80,7 +80,7 @@ func main() {
|
||||
pflag.BoolVarP(&helpFlag, "help", "h", false, "shows Task usage")
|
||||
pflag.BoolVarP(&init, "init", "i", false, "creates a new Taskfile.yaml in the current folder")
|
||||
pflag.BoolVarP(&list, "list", "l", false, "lists tasks with description of current Taskfile")
|
||||
pflag.BoolVarP(&listAll, "list-all", "a", false, "list tasks with or without a description")
|
||||
pflag.BoolVarP(&listAll, "list-all", "a", false, "lists tasks with or without a description")
|
||||
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(&watch, "watch", "w", false, "enables watch of the given task")
|
||||
@@ -156,6 +156,7 @@ func main() {
|
||||
|
||||
if list {
|
||||
e.ListTasksWithDesc()
|
||||
return
|
||||
}
|
||||
|
||||
if listAll {
|
||||
|
@@ -742,6 +742,8 @@ would print the following output:
|
||||
* test: Run all the go tests.
|
||||
```
|
||||
|
||||
If you want to see all tasks, there's a `--list-all` (alias `-a`) flag as well.
|
||||
|
||||
## Display summary of task
|
||||
|
||||
Running `task --summary task-name` will show a summary of a task.
|
||||
|
38
help.go
38
help.go
@@ -9,20 +9,32 @@ import (
|
||||
"github.com/go-task/task/v3/taskfile"
|
||||
)
|
||||
|
||||
// PrintTasksHelp prints tasks' help.
|
||||
// Behavior is governed by listAll. When false, only tasks with descriptions are reported.
|
||||
// When true, all tasks are reported with descriptions shown where available.
|
||||
func (e *Executor) PrintTasksHelp(listAll bool) {
|
||||
// ListTasksWithDesc reports tasks that have a description spec.
|
||||
func (e *Executor) ListTasksWithDesc() {
|
||||
e.pringTasks(false)
|
||||
return
|
||||
}
|
||||
|
||||
// ListAllTasks reports all tasks, with or without a description spec.
|
||||
func (e *Executor) ListAllTasks() {
|
||||
e.pringTasks(true)
|
||||
return
|
||||
}
|
||||
|
||||
func (e *Executor) pringTasks(listAll bool) {
|
||||
var tasks []*taskfile.Task
|
||||
if listAll == true {
|
||||
if listAll {
|
||||
tasks = e.allTaskNames()
|
||||
} else {
|
||||
tasks = e.tasksWithDesc()
|
||||
}
|
||||
|
||||
if len(tasks) == 0 {
|
||||
// TODO: This message should be more informative. Maybe a hint to try -la for showing all?
|
||||
e.Logger.Outf(logger.Yellow, "task: No tasks with description available")
|
||||
if listAll {
|
||||
e.Logger.Outf(logger.Yellow, "task: No tasks available")
|
||||
} else {
|
||||
e.Logger.Outf(logger.Yellow, "task: No tasks with description available. Try --list-all to list all tasks")
|
||||
}
|
||||
return
|
||||
}
|
||||
e.Logger.Outf(logger.Default, "task: Available tasks for this project:")
|
||||
@@ -58,15 +70,3 @@ func (e *Executor) tasksWithDesc() (tasks []*taskfile.Task) {
|
||||
sort.Slice(tasks, func(i, j int) bool { return tasks[i].Task < tasks[j].Task })
|
||||
return
|
||||
}
|
||||
|
||||
// ListTasksWithDesc reports tasks that have a description spec.
|
||||
func (e *Executor) ListTasksWithDesc() {
|
||||
e.PrintTasksHelp(false)
|
||||
return
|
||||
}
|
||||
|
||||
// ListAllTasks reports all tasks, with or without a description spec.
|
||||
func (e *Executor) ListAllTasks() {
|
||||
e.PrintTasksHelp(true)
|
||||
return
|
||||
}
|
||||
|
@@ -518,7 +518,7 @@ func TestLabelInList(t *testing.T) {
|
||||
Stderr: &buff,
|
||||
}
|
||||
assert.NoError(t, e.Setup())
|
||||
e.PrintTasksHelp(false)
|
||||
e.ListTasksWithDesc()
|
||||
assert.Contains(t, buff.String(), "foobar")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user