-
Notifications
You must be signed in to change notification settings - Fork 0
/
completer.go
49 lines (42 loc) · 1.22 KB
/
completer.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
40
41
42
43
44
45
46
47
48
49
package main
import (
"github.com/chzyer/readline"
"github.com/The-Cracker-Technology/fiesta/pkg/core"
)
func (p *fiestaPrompt) listAttacksFunc() func(string) []string {
return func(line string) []string {
return p.listAttacks()
}
}
func (p *fiestaPrompt) listAttacks() []string {
return core.Attacks.DumpCmd()
}
func (p *fiestaPrompt) listOptionsFunc() func(string) []string {
return func(line string) []string {
return p.listOptions()
}
}
func (p *fiestaPrompt) listOptions() []string {
var res []string
for _, v := range p.c.Options() {
res = append(res, v.Param)
}
return res
}
func (p *fiestaPrompt) PrepareCompleter() {
p.CompleterRoot = readline.NewPrefixCompleter(
readline.PcItem("use", readline.PcItemDynamic(p.listAttacksFunc())),
readline.PcItem("show", readline.PcItem("attacks")),
readline.PcItem("clear"),
readline.PcItem("exit"),
)
p.CompleterUse = readline.NewPrefixCompleter(
readline.PcItem("show", readline.PcItem("options")),
readline.PcItem("set", readline.PcItemDynamic(p.listOptionsFunc())),
readline.PcItem("unset", readline.PcItemDynamic(p.listOptionsFunc())),
readline.PcItem("exploit"),
readline.PcItem("clear"),
readline.PcItem("back"),
readline.PcItem("exit"),
)
}