mirror of
https://github.com/go-task/task.git
synced 2025-06-23 00:38:19 +02:00
refactor: taskfile/ast package (#1450)
* refactor: ast package * feat: read -> taskfile * refactor: taskfile.Taskfile -> taskfile.Read * refactor: move merge function back into taskfile package * refactor: rename taskfile.go to read.go
This commit is contained in:
@ -4,10 +4,10 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/go-task/task/v3/internal/logger"
|
||||
"github.com/go-task/task/v3/taskfile"
|
||||
"github.com/go-task/task/v3/taskfile/ast"
|
||||
)
|
||||
|
||||
func PrintTasks(l *logger.Logger, t *taskfile.Taskfile, c []taskfile.Call) {
|
||||
func PrintTasks(l *logger.Logger, t *ast.Taskfile, c []ast.Call) {
|
||||
for i, call := range c {
|
||||
PrintSpaceBetweenSummaries(l, i)
|
||||
PrintTask(l, t.Tasks.Get(call.Task))
|
||||
@ -24,7 +24,7 @@ func PrintSpaceBetweenSummaries(l *logger.Logger, i int) {
|
||||
l.Outf(logger.Default, "\n")
|
||||
}
|
||||
|
||||
func PrintTask(l *logger.Logger, t *taskfile.Task) {
|
||||
func PrintTask(l *logger.Logger, t *ast.Task) {
|
||||
printTaskName(l, t)
|
||||
printTaskDescribingText(t, l)
|
||||
printTaskDependencies(l, t)
|
||||
@ -32,7 +32,7 @@ func PrintTask(l *logger.Logger, t *taskfile.Task) {
|
||||
printTaskCommands(l, t)
|
||||
}
|
||||
|
||||
func printTaskDescribingText(t *taskfile.Task, l *logger.Logger) {
|
||||
func printTaskDescribingText(t *ast.Task, l *logger.Logger) {
|
||||
if hasSummary(t) {
|
||||
printTaskSummary(l, t)
|
||||
} else if hasDescription(t) {
|
||||
@ -42,11 +42,11 @@ func printTaskDescribingText(t *taskfile.Task, l *logger.Logger) {
|
||||
}
|
||||
}
|
||||
|
||||
func hasSummary(t *taskfile.Task) bool {
|
||||
func hasSummary(t *ast.Task) bool {
|
||||
return t.Summary != ""
|
||||
}
|
||||
|
||||
func printTaskSummary(l *logger.Logger, t *taskfile.Task) {
|
||||
func printTaskSummary(l *logger.Logger, t *ast.Task) {
|
||||
lines := strings.Split(t.Summary, "\n")
|
||||
for i, line := range lines {
|
||||
notLastLine := i+1 < len(lines)
|
||||
@ -56,13 +56,13 @@ func printTaskSummary(l *logger.Logger, t *taskfile.Task) {
|
||||
}
|
||||
}
|
||||
|
||||
func printTaskName(l *logger.Logger, t *taskfile.Task) {
|
||||
func printTaskName(l *logger.Logger, t *ast.Task) {
|
||||
l.Outf(logger.Default, "task: ")
|
||||
l.Outf(logger.Green, "%s\n", t.Name())
|
||||
l.Outf(logger.Default, "\n")
|
||||
}
|
||||
|
||||
func printTaskAliases(l *logger.Logger, t *taskfile.Task) {
|
||||
func printTaskAliases(l *logger.Logger, t *ast.Task) {
|
||||
if len(t.Aliases) == 0 {
|
||||
return
|
||||
}
|
||||
@ -74,11 +74,11 @@ func printTaskAliases(l *logger.Logger, t *taskfile.Task) {
|
||||
}
|
||||
}
|
||||
|
||||
func hasDescription(t *taskfile.Task) bool {
|
||||
func hasDescription(t *ast.Task) bool {
|
||||
return t.Desc != ""
|
||||
}
|
||||
|
||||
func printTaskDescription(l *logger.Logger, t *taskfile.Task) {
|
||||
func printTaskDescription(l *logger.Logger, t *ast.Task) {
|
||||
l.Outf(logger.Default, "%s\n", t.Desc)
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ func printNoDescriptionOrSummary(l *logger.Logger) {
|
||||
l.Outf(logger.Default, "(task does not have description or summary)\n")
|
||||
}
|
||||
|
||||
func printTaskDependencies(l *logger.Logger, t *taskfile.Task) {
|
||||
func printTaskDependencies(l *logger.Logger, t *ast.Task) {
|
||||
if len(t.Deps) == 0 {
|
||||
return
|
||||
}
|
||||
@ -99,7 +99,7 @@ func printTaskDependencies(l *logger.Logger, t *taskfile.Task) {
|
||||
}
|
||||
}
|
||||
|
||||
func printTaskCommands(l *logger.Logger, t *taskfile.Task) {
|
||||
func printTaskCommands(l *logger.Logger, t *ast.Task) {
|
||||
if len(t.Cmds) == 0 {
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user