aboutsummaryrefslogtreecommitdiff
path: root/cmd/eno/cobra_config.go
diff options
context:
space:
mode:
authorishaan <contact@ishaan.cc>2026-07-21 20:36:04 +0530
committerishaan <contact@ishaan.cc>2026-07-21 20:36:04 +0530
commita92d0201b50c5c8e87638bd2ebb2e9e2b5b0983c (patch)
treebaa134e8baa73a5f6094ea56bb83d7e8603dfdef /cmd/eno/cobra_config.go
parente48a02646f60b6fdff8db5c4105896756584ac63 (diff)
update gitignore so CI tests don't fail, update filenames
Diffstat (limited to 'cmd/eno/cobra_config.go')
-rw-r--r--cmd/eno/cobra_config.go71
1 files changed, 71 insertions, 0 deletions
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 <key> <value...>",
+ 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 <key>",
+ 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 <key> [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])
+ },
+}