package main import ( "html" "io/ioutil" "os/exec" "strings" ) type Command struct { name string description string } type Group struct { name string commands []Command } func main() { first := run("help") split := strings.Split(first, "\n") groups := make([]Group, 0) commands := make([]Command, 0) lastGroupName := "" for _, line := range split { if len(line) > 0 { if strings.HasPrefix(line, "== ") { if len(commands) != 0 { g := Group{ name: lastGroupName, commands: commands, } groups = append(groups, g) commands = make([]Command, 0) } lastGroupName = line[3 : len(line)-3] } else { name := strings.Split(line, " ")[0] desc := run("help", name) desc = html.EscapeString(desc) comm := Command{ name: name, description: desc, } commands = append(commands, comm) } } } g := Group{ name: lastGroupName, commands: commands, } groups = append(groups, g) menuStr := "" for _, group := range groups { menuStr += `