From a92d0201b50c5c8e87638bd2ebb2e9e2b5b0983c Mon Sep 17 00:00:00 2001 From: ishaan Date: Tue, 21 Jul 2026 20:36:04 +0530 Subject: update gitignore so CI tests don't fail, update filenames --- cmd/eno/cobra_config.go | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 cmd/eno/cobra_config.go (limited to 'cmd/eno/cobra_config.go') diff --git a/cmd/eno/cobra_config.go b/cmd/eno/cobra_config.go new file mode 100644 index 0000000..0872b28 --- /dev/null +++ b/cmd/eno/cobra_config.go @@ -0,0 +1,71 @@ +package main + +import ( + "fmt" + "strings" + + "github.com/spf13/cobra" + "gitlab.com/whiteboardguy/eno/internal/config" +) + +var configCmd = &cobra.Command{ + Use: "config", + Short: "manage eno configuration", +} + +var configSetCmd = &cobra.Command{ + Use: "set ", + Short: "set a config value", + Args: cobra.MinimumNArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + if err := config.HandlerInit(); err != nil { + return err + } + key := strings.ToUpper(args[0]) + if key == "PUBKEY_SERVICES" { + if len(args) < 3 { + return fmt.Errorf("pubkey_services requires name and url template") + } + return config.PubkeyServiceAdd(args[1], strings.Join(args[2:], " ")) + } + return config.Set(key, strings.Join(args[1:], " ")) + }, +} + +var configGetCmd = &cobra.Command{ + Use: "get ", + Short: "get a config value", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + val, err := config.Get(args[0]) + if err != nil { + return err + } + cmd.Println(val) + return nil + }, +} + +var configListCmd = &cobra.Command{ + Use: "list", + Short: "list all config values", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + for _, line := range config.List() { + cmd.Println(line) + } + return nil + }, +} + +var configRemoveCmd = &cobra.Command{ + Use: "remove [name]", + Short: "remove a config value or pubkey service", + Args: cobra.MinimumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + if strings.ToUpper(args[0]) == "PUBKEY_SERVICES" && len(args) >= 2 { + return config.PubkeyServiceRemove(args[1]) + } + return config.Remove(args[0]) + }, +} -- cgit v1.3