mirror of
https://github.com/nxshock/gron.git
synced 2024-11-27 03:41:00 +05:00
21 lines
342 B
Go
21 lines
342 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
func parseCommand(s string) (command string, params []string) {
|
||
|
quoted := false
|
||
|
items := strings.FieldsFunc(s, func(r rune) bool {
|
||
|
if r == '"' {
|
||
|
quoted = !quoted
|
||
|
}
|
||
|
return !quoted && r == ' '
|
||
|
})
|
||
|
for i := range items {
|
||
|
items[i] = strings.Trim(items[i], `"`)
|
||
|
}
|
||
|
|
||
|
return items[0], items[1:]
|
||
|
}
|