Skip to content

Commit 3614f1c

Browse files
committed
Add details to CLI header
1 parent e9f5500 commit 3614f1c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

pkg/renderer/printer.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ func (p *Printer) startText() string {
5151
Sprintf(p.BuildInfo["version"])
5252

5353
text := fmt.Sprintf("%s %s\nListening on http://%s:%d", primary, version, p.Addr, p.Port)
54+
55+
if p.Details {
56+
text = fmt.Sprintf("%s\nDetails: %t", text, p.Details)
57+
}
58+
5459
return text
5560
}
5661

pkg/renderer/printer_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ func TestStartText(t *testing.T) {
1919
}
2020
}
2121

22+
func TestStartTextWithDetails(t *testing.T) {
23+
pterm.DisableColor()
24+
printer := Printer{
25+
Addr: "localhost",
26+
Port: 8080,
27+
BuildInfo: map[string]string{"version": "dev"},
28+
Details: true}
29+
result := printer.startText()
30+
expected := fmt.Sprintf(
31+
"Request Hole %s\nListening on http://%s:%d\nDetails: %t", "dev",
32+
printer.Addr, printer.Port, printer.Details)
33+
34+
if result != expected {
35+
t.Errorf("Expected %s, got %s", expected, result)
36+
}
37+
}
38+
2239
func TestIncomingRequestText(t *testing.T) {
2340
pterm.DisableColor()
2441
printer := Printer{}

0 commit comments

Comments
 (0)