Browse Source

Capitalize first letters of file result messages

renovate/configure
Yota Toyama 8 years ago
parent
commit
74dae64068
  1. 2
      file_result.go
  2. 4
      main.go
  3. 10
      utils.go
  4. 9
      utils_test.go

2
file_result.go

@ -17,7 +17,7 @@ func (r fileResult) String(verbose bool) string {
ss := make([]string, 0, len(r.urlResults)) ss := make([]string, 0, len(r.urlResults))
if r.err != nil { if r.err != nil {
ss = append(ss, indent(color.RedString(r.err.Error()))) ss = append(ss, indent(color.RedString(capitalizeFirst(r.err.Error()))))
} }
os := make([]string, 0, len(r.urlResults)) os := make([]string, 0, len(r.urlResults))

4
main.go

@ -3,7 +3,6 @@ package main
import ( import (
"fmt" "fmt"
"os" "os"
"strings"
"sync" "sync"
"github.com/fatih/color" "github.com/fatih/color"
@ -59,7 +58,6 @@ func printToStderr(xs ...interface{}) {
} }
func fail(err error) { func fail(err error) {
s := err.Error() printToStderr(color.RedString(capitalizeFirst(err.Error())))
printToStderr(color.RedString(strings.ToUpper(s[:1]) + s[1:]))
os.Exit(1) os.Exit(1)
} }

10
utils.go

@ -1,6 +1,10 @@
package main package main
import "github.com/kr/text" import (
"strings"
"github.com/kr/text"
)
func stringSetToSlice(s2b map[string]bool) []string { func stringSetToSlice(s2b map[string]bool) []string {
ss := make([]string, 0, len(s2b)) ss := make([]string, 0, len(s2b))
@ -15,3 +19,7 @@ func stringSetToSlice(s2b map[string]bool) []string {
func indent(s string) string { func indent(s string) string {
return text.Indent(s, "\t") return text.Indent(s, "\t")
} }
func capitalizeFirst(s string) string {
return strings.ToUpper(s[:1]) + s[1:]
}

9
utils_test.go

@ -25,3 +25,12 @@ func TestIndent(t *testing.T) {
assert.Equal(t, c.target, indent(c.source)) assert.Equal(t, c.target, indent(c.source))
} }
} }
func TestCapitalizeFirst(t *testing.T) {
for _, ss := range [][2]string{
{"foo", "Foo"},
{"foo bar", "Foo bar"},
} {
assert.Equal(t, ss[1], capitalizeFirst(ss[0]))
}
}

Loading…
Cancel
Save