Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Jul 18, 2022
1 parent e008fe6 commit c6c1d68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 12 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package carapace

import (
"strings"

"github.com/rsteube/carapace/internal/config"
)

Expand All @@ -22,6 +24,10 @@ func init() {
config.RegisterConfig("carapace", &conf)
}

type configI interface {
Completion() ActionMap
}

func ActionConfigs() Action {
return ActionMultiParts("=", func(c Context) Action {
switch len(c.Parts) {
Expand All @@ -41,6 +47,12 @@ func ActionConfigs() Action {
}
})
case 1:
if m := config.GetConfigMap(strings.Split(c.Parts[0], ".")[0]); m != nil {
if i, ok := m.(configI); ok {
// TODO check splitted length
return i.Completion()[strings.Split(c.Parts[0], ".")[1]]
}
}
return ActionValues()
default:
return ActionValues()
Expand Down
6 changes: 4 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ func SetConfig(key, value string) error {

func GetConfigs() []string { return config.Configs.Keys() }
func GetConfigFields(name string) ([]string, error) { return config.Configs.Fields(name, false) }
func GetStyleConfigs() []string { return config.Styles.Keys() }
func GetStyleFields(name string) ([]string, error) { return config.Styles.Fields(name, true) }
func GetConfigMap(name string) interface{} { return config.Configs[name] }

func GetStyleConfigs() []string { return config.Styles.Keys() }
func GetStyleFields(name string) ([]string, error) { return config.Styles.Fields(name, true) }
func SetStyle(key, value string) error {
return set("styles", key, strings.Replace(value, ",", " ", -1))
}
Expand Down

0 comments on commit c6c1d68

Please sign in to comment.