diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/utils.go | 6 | ||||
-rw-r--r-- | utils/utils_test.go | 18 |
2 files changed, 11 insertions, 13 deletions
diff --git a/utils/utils.go b/utils/utils.go index eaa6c09a9..ea89ec745 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -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]) } diff --git a/utils/utils_test.go b/utils/utils_test.go index 0bb92dea8..7c47ef970 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -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 { |