ref: 581c0764699f92cbdde239602e69fb40662628e4
dir: /commands.go/
package main
import (
"strings"
)
var commands = []string{"examine", "reply", "like", "thread", "open", "preview", "download", "dm", "rt", "parent", "children", "rm", "mark", "unmark", "account", "vim", "import", "pause", "resume"}
func processInput(input string) (command string, arguments string) {
if input == "" {
command = ""
arguments = ""
return
}
if input[0] != '/' {
command = ""
arguments = input
return
}
inputcommand, _, hasargument := strings.Cut(input[1:], " ")
if !hasargument {
inputcommand = input[1:]
}
for _, choice := range commands {
if strings.HasPrefix(choice, inputcommand) {
command = choice
_, arguments, _ = strings.Cut(input, " ")
return
}
}
return
}