Skip to content

Commit 4bf4d56

Browse files
committed
cli-plugins/hooks: PrintNextSteps: slight cleanup
- skip aec to construct the formatting and use a const instead - skip fmt.Println and write directly to the writer - move newlines outside of the "bold" formatting Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent dd1f7f5 commit 4bf4d56

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

cli-plugins/hooks/printer.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package hooks
22

3-
import (
4-
"fmt"
5-
"io"
3+
import "io"
64

7-
"github.com/morikuni/aec"
5+
const (
6+
whatsNext = "\n\033[1mWhat's next:\033[0m\n"
7+
indent = " "
88
)
99

1010
// PrintNextSteps renders list of [NextSteps] messages and writes them
@@ -13,8 +13,11 @@ func PrintNextSteps(out io.Writer, messages []string) {
1313
if len(messages) == 0 {
1414
return
1515
}
16-
_, _ = fmt.Fprintln(out, aec.Bold.Apply("\nWhat's next:"))
17-
for _, n := range messages {
18-
_, _ = fmt.Fprintln(out, " ", n)
16+
17+
_, _ = io.WriteString(out, whatsNext)
18+
for _, msg := range messages {
19+
_, _ = io.WriteString(out, indent)
20+
_, _ = io.WriteString(out, msg)
21+
_, _ = io.WriteString(out, "\n")
1922
}
2023
}

cli-plugins/hooks/printer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
func TestPrintHookMessages(t *testing.T) {
12-
const header = "\x1b[1m\nWhat's next:\x1b[0m\n"
12+
const header = "\n\x1b[1mWhat's next:\x1b[0m\n"
1313

1414
tests := []struct {
1515
doc string

0 commit comments

Comments
 (0)