Files
WatchDog_Linux-systemd/command/commandParse.go

41 lines
735 B
Go

package command
import (
"strings"
)
func getTextMiddle(text, left, right string) string {
start := 0
if left != "" {
idx := strings.Index(text, left)
if idx == -1 {
return ""
}
start = idx + len(left)
}
if right == "" {
if start > len(text) {
return ""
}
return text[start:]
}
endIdx := strings.Index(text[start:], right)
if endIdx == -1 {
return ""
}
return text[start : start+endIdx]
}
func getCommand(content string) string {
return getTextMiddle(content, "[", "]")
}
func parseCommand(content, cmdType string) string {
return getTextMiddle(content, "<" + cmdType + ">", "</" + cmdType + ">")
}
func ExecuteCommand(input string) error {
return nil
}