init code
This commit is contained in:
25
internal/services/tele/commands/helper/arg.go
Normal file
25
internal/services/tele/commands/helper/arg.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package helper
|
||||
|
||||
import "strings"
|
||||
|
||||
func Args2String(args []string) (string, error) {
|
||||
if len(args) != 1 {
|
||||
return "", ErrorParamCountMismatch
|
||||
}
|
||||
return args[0], nil
|
||||
}
|
||||
|
||||
func Args2StringString(args []string) (string, string, error) {
|
||||
if len(args) != 2 {
|
||||
return "", "", ErrorParamCountMismatch
|
||||
}
|
||||
return args[0], args[1], nil
|
||||
}
|
||||
|
||||
func Args2Bool(args []string) (bool, error) {
|
||||
if len(args) != 1 {
|
||||
return false, ErrorParamCountMismatch
|
||||
}
|
||||
val := strings.ToUpper(args[0])
|
||||
return val == "1" || val == "TRUE", nil
|
||||
}
|
||||
Reference in New Issue
Block a user