-
Notifications
You must be signed in to change notification settings - Fork 7
/
commands.go
79 lines (67 loc) · 1.32 KB
/
commands.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package modules
import (
"context"
"github.com/abenz1267/walker/config"
)
type Commands struct {
prefix string
switcherExclusive bool
entries []Entry
}
func (c Commands) Entries(ctx context.Context, term string) []Entry {
return c.entries
}
func (c Commands) Prefix() string {
return c.prefix
}
func (c Commands) Name() string {
return "commands"
}
func (c Commands) SwitcherExclusive() bool {
return c.switcherExclusive
}
func (cc Commands) Setup(cfg *config.Config) Workable {
module := Find(cfg.Modules, cc.Name())
if module == nil {
return nil
}
c := &Commands{
prefix: module.Prefix,
switcherExclusive: module.SwitcherExclusive,
entries: []Entry{},
}
entries := []struct {
label string
exec string
}{
{
label: "Reload Config",
exec: "reloadconfig",
},
{
label: "Reset History",
exec: "resethistory",
},
{
label: "Clear Clipboard",
exec: "clearclipboard",
},
{
label: "Clear Applications Cache",
exec: "clearapplicationscache",
},
{
label: "Clear Typeahead Cache",
exec: "cleartypeaheadcache",
},
}
for _, v := range entries {
c.entries = append(c.entries, Entry{
Label: v.label,
Sub: "Walker",
Exec: v.exec,
RecalculateScore: true,
})
}
return c
}