Skip to content

Commit afe765d

Browse files
Attempt to make CLI output clearer
1 parent ad5b8a1 commit afe765d

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

pkg/runner/display.go

+15-9
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ func multiLineWrite(out io.StringWriter, prefix, lines string) {
110110
}
111111

112112
func (d *display) printState(s state, depth int) string {
113-
if !s.Running {
114-
return ""
115-
}
116-
117113
buf := &strings.Builder{}
118114
prefix := strings.Repeat(" ", depth)
119115
inPrefix := prefix + " |<- "
@@ -124,24 +120,34 @@ func (d *display) printState(s state, depth int) string {
124120
if name == "" {
125121
name = "main"
126122
}
127-
buf.WriteString("(running ")
123+
if s.Running {
124+
buf.WriteString("(running ")
125+
} else {
126+
buf.WriteString("(done ")
127+
}
128128
buf.WriteString(name)
129129
buf.WriteString(")\n")
130130
if s.Input != "" {
131131
multiLineWrite(buf, inPrefix, "args: "+s.Input)
132132
}
133133

134+
childRunning := false
134135
for _, state := range d.states {
135136
if state.Context != nil && state.Context.Parent != nil && state.Context.Parent.ID == s.Context.ID {
137+
if state.Running {
138+
childRunning = true
139+
}
136140
buf.WriteString(d.printState(state, depth+1))
137141
}
138142
}
139143

140-
if len(s.Input) > 0 && len(s.Output) > 0 {
141-
multiLineWrite(buf, outPrefix, "---")
142-
}
144+
if depth == 0 && !childRunning {
145+
if len(s.Input) > 0 && len(s.Output) > 0 {
146+
multiLineWrite(buf, outPrefix, "---")
147+
}
143148

144-
multiLineWrite(buf, outPrefix, s.Output)
149+
multiLineWrite(buf, outPrefix, s.Output)
150+
}
145151

146152
return buf.String()
147153
}

0 commit comments

Comments
 (0)