github.com/sunriselayer/sunrise-da@v0.13.1-sr3/cmd/config.go (about) 1 package cmd 2 3 import ( 4 "github.com/spf13/cobra" 5 flag "github.com/spf13/pflag" 6 7 "github.com/sunriselayer/sunrise-da/nodebuilder" 8 ) 9 10 func RemoveConfigCmd(fsets ...*flag.FlagSet) *cobra.Command { 11 cmd := &cobra.Command{ 12 Use: "config-remove", 13 Short: "Deletes the node's config", 14 Args: cobra.NoArgs, 15 RunE: func(cmd *cobra.Command, args []string) error { 16 ctx := cmd.Context() 17 return nodebuilder.RemoveConfig(StorePath(ctx)) 18 }, 19 } 20 21 for _, set := range fsets { 22 cmd.Flags().AddFlagSet(set) 23 } 24 return cmd 25 } 26 27 func UpdateConfigCmd(fsets ...*flag.FlagSet) *cobra.Command { 28 cmd := &cobra.Command{ 29 Use: "config-update", 30 Short: "Updates the node's outdated config", 31 Long: "Updates the node's outdated config with default values from newly-added fields. Check the config " + 32 " afterwards to ensure all old custom values were preserved.", 33 Args: cobra.NoArgs, 34 RunE: func(cmd *cobra.Command, args []string) error { 35 ctx := cmd.Context() 36 return nodebuilder.UpdateConfig(NodeType(ctx), StorePath(ctx)) 37 }, 38 } 39 40 for _, set := range fsets { 41 cmd.Flags().AddFlagSet(set) 42 } 43 return cmd 44 }