-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
config.go
40 lines (34 loc) · 1012 Bytes
/
config.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
package action
import (
"strings"
"github.com/carapace-sh/carapace"
)
func ActionConfigs() carapace.Action {
return carapace.ActionExecCommand("qmk", "config", "--all")(func(output []byte) carapace.Action {
lines := strings.Split(string(output), "\n")
vals := make([]string, 0)
for _, line := range lines[:len(lines)-1] {
if splitted := strings.SplitN(line, "=", 2); len(splitted) == 2 {
vals = append(vals, splitted...)
}
}
return carapace.ActionValuesDescribed(vals...)
})
}
func ActionConfigValues(name string) carapace.Action {
return carapace.ActionCallback(func(c carapace.Context) carapace.Action {
// TODO more configs
switch name {
case "multibuild.keymap":
return ActionKeymaps("")
case "user.keyboard":
return ActionKeyboards().Invoke(c).ToMultiPartsA("/")
case "user.keymap":
return ActionKeymaps("") // TODO user user.keyboard config
case "setup.home":
return carapace.ActionDirectories()
default:
return carapace.ActionValues()
}
})
}