ref: 0a7455c6a861565d74e3bff9d0cd87bd391db14f
dir: /commands.go/
package main
import (
"strings"
)
var commands = []string{"examine", "reply", "like", "thread", "open", "preview", "dm", "rt", "parent", "children", "rm", "download", "mark", "unmark"}
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
}