feat(command): add command parsing

This commit is contained in:
2026-04-04 13:44:48 +08:00
parent 0f6045bcbd
commit b367323801
2 changed files with 47 additions and 1 deletions

41
commandParse.go Normal file
View File

@@ -0,0 +1,41 @@
package main
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
}