Add helper to split the command and arguments
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
35c72daff4
commit
6a389be6a7
@ -68,3 +68,21 @@ func HasCommand(s, prefix, cmd string) bool {
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SplitCommandAndArgs(s, prefix string) (cmd string, args []string) {
|
||||||
|
s = strings.TrimSpace(s)
|
||||||
|
|
||||||
|
x := strings.Split(s, " ")
|
||||||
|
|
||||||
|
if len(x) > 1 {
|
||||||
|
args = x[1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = x[0]
|
||||||
|
|
||||||
|
if strings.Index(s, prefix) == 0 {
|
||||||
|
cmd = cmd[len(prefix):]
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd, args
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user