Skip to content

Commit b51eaf2

Browse files
committed
release: v1.3.2
1 parent eca6c8f commit b51eaf2

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

box.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type Box struct {
2525
BottomRight string // BottomRight corner used for Symbols
2626
BottomLeft string // BotromLeft corner used for Symbols
2727
Horizontal string // Symbols used for Horizontal Bars
28-
Con Config // Config for Box struct
28+
Con Config // Config for the Box struct
2929
}
3030

3131
// Config is the configuration for the Box struct
@@ -57,7 +57,7 @@ func (b Box) String(title, lines string) string {
5757
if b.Con.TitlePos == "" {
5858
b.Con.TitlePos = "Inside"
5959
}
60-
60+
// if Title is empty then TitlePos should be Inside
6161
if title != "" {
6262
if b.Con.TitlePos != "Inside" && strings.Contains(title, "\n") {
6363
panic("Multilines are only supported inside only")
@@ -71,7 +71,7 @@ func (b Box) String(title, lines string) string {
7171
return b.toString(title, lines2)
7272
}
7373

74-
// toString is same as String except this is for printing Boxes
74+
// toString is same as String except that it is used for printing Boxes
7575
func (b Box) toString(title string, lines []string) string {
7676
titleLen := len(strings.Split(title, n1))
7777
sideMargin := strings.Repeat(" ", b.Con.Px)
@@ -98,7 +98,7 @@ func (b Box) toString(title string, lines []string) string {
9898
} else if b.Con.TitlePos == "Bottom" {
9999
BottomBar = b.BottomLeft + TitleBar + b.BottomRight
100100
} else {
101-
fmt.Fprintln(os.Stderr, "Invalid TitlePos provided, using default")
101+
fmt.Fprintln(os.Stderr, color.RedString("[error]: invalid value provided for TitlePos, using default"))
102102
}
103103
}
104104

@@ -115,12 +115,12 @@ func (b Box) toString(title string, lines []string) string {
115115
TopBar = Style(TopBar)
116116
BottomBar = Style(BottomBar)
117117
} else {
118-
fmt.Fprintln(os.Stderr, "Invalid Color Type provided, using default color")
118+
fmt.Fprintln(os.Stderr, color.RedString("[error]: invalid value provided to Color, using default"))
119119
}
120120
}
121121

122122
if b.Con.TitlePos == "Inside" && runewidth.StringWidth(TopBar) != runewidth.StringWidth(BottomBar) {
123-
panic("Cannot create a Box with different sizes of Top and Bottom Bars")
123+
panic("cannot create a Box with different sizes of Top and Bottom Bars")
124124
}
125125

126126
// create lines to print
@@ -156,7 +156,7 @@ func (b Box) toString(title string, lines []string) string {
156156
if i < titleLen && title != "" {
157157
format = centerAlign
158158
}
159-
159+
// obtain color
160160
sep := b.obtainColor()
161161

162162
// TODO: find a better way
@@ -179,7 +179,7 @@ func (b Box) obtainColor() string {
179179
Style := color.New(fgColors[b.Con.Color]).SprintfFunc()
180180
return Style(b.Vertical)
181181
}
182-
fmt.Fprintln(os.Stderr, "Invalid Color Type provided, using default color")
182+
fmt.Fprintln(os.Stderr, color.RedString("[error]: invalid value provided to Color, using default"))
183183
return b.Vertical
184184
}
185185

@@ -191,7 +191,7 @@ func (b Box) Print(title, lines string) {
191191
if b.Con.TitlePos == "" {
192192
b.Con.TitlePos = "Inside"
193193
}
194-
194+
// if Title is empty then TitlePos should be Inside
195195
if title != "" {
196196
if b.Con.TitlePos != "Inside" && strings.Contains(title, "\n") {
197197
panic("Multilines are only supported inside only")
@@ -213,7 +213,7 @@ func (b Box) Println(title, lines string) {
213213
if b.Con.TitlePos == "" {
214214
b.Con.TitlePos = "Inside"
215215
}
216-
216+
// if Title is empty then TitlePos should be Inside
217217
if title != "" {
218218
if b.Con.TitlePos != "Inside" && strings.Contains(title, "\n") {
219219
panic("Multilines are only supported inside only")

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.14
44

55
require (
66
github.com/fatih/color v1.9.0
7-
github.com/mattn/go-colorable v0.1.6 // indirect
7+
github.com/mattn/go-colorable v0.1.7 // indirect
88
github.com/mattn/go-runewidth v0.0.9
9-
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect
9+
golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c // indirect
1010
)

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaa
44
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
55
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
66
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
7+
github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw=
8+
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
79
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
810
github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
911
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
@@ -20,3 +22,5 @@ golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 h1:YTzHMGlqJu67/uEo1lBv0n3wB
2022
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
2123
golang.org/x/sys v0.0.0-20200523222454-059865788121 h1:rITEj+UZHYC927n8GT97eC3zrpzXdb/voyeOuVKS46o=
2224
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
25+
golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c h1:UIcGWL6/wpCfyGuJnRFJRurA+yj8RrW7Q6x2YMCXt6c=
26+
golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

util.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66
"strings"
77

8+
"github.com/fatih/color"
89
"github.com/mattn/go-runewidth"
910
)
1011

@@ -29,7 +30,7 @@ func (b Box) findAlign() string {
2930
} else if b.Con.ContentAlign == "Left" {
3031
return leftAlign
3132
} else {
32-
fmt.Fprintln(os.Stderr, "Invalid Alignment provided, using default Alignment")
33+
fmt.Fprintln(os.Stderr, color.RedString("[error]: invalid value provided to Alignment, using default"))
3334
return leftAlign
3435
}
3536
}

0 commit comments

Comments
 (0)