Skip to content

Commit

Permalink
Format task description similar to gradle 'tasks' task
Browse files Browse the repository at this point in the history
If --with-description is given, print task description on the same
line as task name.
  • Loading branch information
dorongold committed Mar 29, 2024
1 parent 8586289 commit e3ff884
Showing 1 changed file with 7 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ abstract class TaskTreeTaskBase extends ProjectBasedReportTask {
styledTextOutput.text(" *")
}

if (withDescription && taskNode.task.description) {
printTaskDescription(graphRenderer, taskNode.task.description, Description)
}

if (withInputs) {
printTaskFiles(graphRenderer, taskNode.task.inputs.files, "<- ", FailureHeader, Failure)
}
Expand All @@ -129,10 +133,6 @@ abstract class TaskTreeTaskBase extends ProjectBasedReportTask {
printTaskFiles(graphRenderer, taskNode.task.outputs.files, "-> ", SuccessHeader, Success)
}

if (withDescription) {
printTaskDescription(graphRenderer, taskNode.task.description, "-> ", Description, Description)
}

}, lastChild)

if (skippingChildren) {
Expand All @@ -147,19 +147,10 @@ abstract class TaskTreeTaskBase extends ProjectBasedReportTask {
}
}

static void printTaskDescription(GraphRenderer graphRenderer, String description, String prefix, StyledTextOutput.Style prefixStyle, StyledTextOutput.Style textStyle) {
graphRenderer.startChildren()
graphRenderer.output.println()
graphRenderer.output
.withStyle(Info)
.text(graphRenderer.prefix)
graphRenderer.output
.withStyle(prefixStyle)
.text(" " * 5 + "${prefix} ")
static void printTaskDescription(GraphRenderer graphRenderer, String description, StyledTextOutput.Style textStyle) {
graphRenderer.output
.withStyle(textStyle)
.text(description)
graphRenderer.completeChildren()
.text(" - " + description)
}

static void printTaskFiles(GraphRenderer graphRenderer, FileCollection files, String prefix, StyledTextOutput.Style prefixStyle, StyledTextOutput.Style textStyle) {
Expand Down Expand Up @@ -207,12 +198,7 @@ abstract class TaskTreeTaskBase extends ProjectBasedReportTask {
textOutput.withStyle(SuccessHeader).println(" ->")
}

if (withDescription) {
textOutput.text("Task description is shown in green and prefixed with")
textOutput.withStyle(SuccessHeader).println(" ->")
}

if (withInputs || withOutputs || withDescription) {
if (withInputs || withOutputs) {
textOutput.println()
}

Expand Down

0 comments on commit e3ff884

Please sign in to comment.