-
Notifications
You must be signed in to change notification settings - Fork 10
/
help.go
39 lines (30 loc) · 889 Bytes
/
help.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package commands
import (
"sort"
"github.com/AbGuthrie/goquery/v2/config"
"github.com/AbGuthrie/goquery/v2/models"
"github.com/AbGuthrie/goquery/v2/utils"
prompt "github.com/c-bata/go-prompt"
)
func help(api models.GoQueryAPI, config *config.Config, cmdline string) error {
commandNames := make([]string, 0)
for k, _ := range CommandMap {
commandNames = append(commandNames, k)
}
sort.Strings(commandNames)
helpRows := make([]map[string]string, 0)
for _, commandName := range commandNames {
helpRows = append(helpRows, map[string]string{
"command": commandName,
"description": CommandMap[commandName].Help(),
})
}
utils.PrettyPrintQueryResults(helpRows, config.PrintMode)
return nil
}
func helpHelp() string {
return "Show the help strings for all goquery commands"
}
func helpSuggest(cmdline string) []prompt.Suggest {
return []prompt.Suggest{}
}