mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-11 05:54:58 +00:00
Apply gofmt -s
This commit is contained in:
@@ -45,13 +45,13 @@ func StopOnErr(err error, s ...string) {
|
||||
|
||||
// cutUsageMessage splits the incoming string on the beginning of the usage
|
||||
// message text. Anything in the first element of the returned slice, trimmed
|
||||
// of its Unicode defined spaces, should be returned. The 2nd element of the
|
||||
// of its Unicode defined spaces, should be returned. The 2nd element of the
|
||||
// slice will have the usage message that we wish to elide.
|
||||
//
|
||||
// This is done because Cobra already prints Hugo's usage message; not eliding
|
||||
// would result in the usage output being printed twice, which leads to bug
|
||||
// would result in the usage output being printed twice, which leads to bug
|
||||
// reports, more specifically: https://github.com/spf13/hugo/issues/374
|
||||
func cutUsageMessage(s string) string {
|
||||
pieces := strings.Split(s, "Usage of")
|
||||
pieces := strings.Split(s, "Usage of")
|
||||
return strings.TrimSpace(pieces[0])
|
||||
}
|
||||
|
||||
@@ -2,21 +2,19 @@ package utils
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
||||
)
|
||||
|
||||
func TestCutUsageMessage(t *testing.T) {
|
||||
tests := []struct{
|
||||
message string
|
||||
tests := []struct {
|
||||
message string
|
||||
cutMessage string
|
||||
}{
|
||||
{"", ""},
|
||||
{" Usage of hugo: \n -b, --baseUrl=...", ""},
|
||||
{"Some error Usage of hugo: \n", "Some error"},
|
||||
{"Usage of hugo: \n -b --baseU", ""},
|
||||
{"CRITICAL error for usage of hugo ", "CRITICAL error for usage of hugo"},
|
||||
{"Invalid short flag a in -abcde", "Invalid short flag a in -abcde"},
|
||||
{" Usage of hugo: \n -b, --baseUrl=...", ""},
|
||||
{"Some error Usage of hugo: \n", "Some error"},
|
||||
{"Usage of hugo: \n -b --baseU", ""},
|
||||
{"CRITICAL error for usage of hugo ", "CRITICAL error for usage of hugo"},
|
||||
{"Invalid short flag a in -abcde", "Invalid short flag a in -abcde"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
Reference in New Issue
Block a user