mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 18:20:13 -08:00
review fixes
This commit is contained in:
parent
f10ed05f86
commit
38b228af6a
4 changed files with 67 additions and 40 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue