github.com/sunriselayer/sunrise-da@v0.13.1-sr3/cmd/init.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  // Init constructs a CLI command to initialize Celestia Node of any type with the given flags.
    11  func Init(fsets ...*flag.FlagSet) *cobra.Command {
    12  	cmd := &cobra.Command{
    13  		Use:   "init",
    14  		Short: "Initialization for Sunrise Node. Passed flags have persisted effect.",
    15  		Args:  cobra.NoArgs,
    16  		RunE: func(cmd *cobra.Command, args []string) error {
    17  			ctx := cmd.Context()
    18  
    19  			return nodebuilder.Init(NodeConfig(ctx), StorePath(ctx), NodeType(ctx))
    20  		},
    21  	}
    22  	for _, set := range fsets {
    23  		cmd.Flags().AddFlagSet(set)
    24  	}
    25  	return cmd
    26  }