1
0
Fork 0
forked from External/ergo

review fixes

This commit is contained in:
Shivaram Lingamneni 2019-05-20 02:56:49 -04:00
parent f10ed05f86
commit 38b228af6a
4 changed files with 67 additions and 40 deletions

View file

@ -3,6 +3,15 @@
package utils
import (
"errors"
"strings"
)
var (
ErrInvalidParams = errors.New("Invalid parameters")
)
// ArgsToStrings takes the arguments and splits them into a series of strings,
// each argument separated by delim and each string bounded by maxLength.
func ArgsToStrings(maxLength int, arguments []string, delim string) []string {
@ -33,3 +42,15 @@ func ArgsToStrings(maxLength int, arguments []string, delim string) []string {
return messages
}
func StringToBool(str string) (result bool, err error) {
switch strings.ToLower(str) {
case "on", "true", "t", "yes", "y":
result = true
case "off", "false", "f", "no", "n":
result = false
default:
err = ErrInvalidParams
}
return
}