Skip to content

Commit 0612a27

Browse files
committed
one line
1 parent 7ac6301 commit 0612a27

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

cli/root.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"os"
1414
"os/signal"
1515
"path/filepath"
16-
"regexp"
1716
"runtime"
1817
"strings"
1918
"syscall"
@@ -825,6 +824,8 @@ type prettyErrorFormatter struct {
825824

826825
func (p *prettyErrorFormatter) format(err error) {
827826
if err == nil {
827+
// 🍒
828+
p.printf("\n")
828829
return
829830
}
830831

@@ -852,8 +853,8 @@ func (p *prettyErrorFormatter) format(err error) {
852853
} else {
853854
msg = errorWithoutChildren
854855
}
855-
p.wrappedPrintf(
856-
"%s\n",
856+
p.printf(
857+
"%s",
857858
textStyle.Render(msg),
858859
)
859860

@@ -864,23 +865,16 @@ func (p *prettyErrorFormatter) format(err error) {
864865

865866
textStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#969696")).Bold(false)
866867

867-
p.wrappedPrintf(
868+
p.printf(
868869
"%s",
869-
textStyle.Render(errorWithoutChildren),
870+
textStyle.Render(": "+errorWithoutChildren),
870871
)
871872
p.level++
872873
p.format(underErr)
873874
}
874875

875-
func (p *prettyErrorFormatter) wrappedPrintf(format string, a ...interface{}) {
876-
s := lipgloss.NewStyle().Width(ttyWidth()).Render(
877-
fmt.Sprintf(format, a...),
878-
)
879-
880-
// Not sure why, but lipgloss is adding extra spaces we need to remove.
881-
excessSpaceRe := regexp.MustCompile(`[[:blank:]]*\n[[:blank:]]*$`)
882-
s = excessSpaceRe.ReplaceAllString(s, "\n")
883-
876+
func (p *prettyErrorFormatter) printf(format string, a ...interface{}) {
877+
s := fmt.Sprintf(format, a...)
884878
_, _ = p.w.Write(
885879
[]byte(
886880
s,

cli/root_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ func TestCommandHelp(t *testing.T) {
4242
cmd []string
4343
}
4444
tests := []testCase{
45-
{
46-
name: "coder --help",
47-
cmd: []string{"--help"},
48-
},
4945
{
5046
name: "coder --help",
5147
cmd: []string{"--help"},

0 commit comments

Comments
 (0)