github.com/weplanx/server@v0.2.6-0.20240318110640-f7e75155779a/cmd/setup.go (about)

     1  package cmd
     2  
     3  import (
     4  	"github.com/spf13/cobra"
     5  	"github.com/weplanx/server/api"
     6  	"github.com/weplanx/server/bootstrap"
     7  	"github.com/weplanx/server/common"
     8  )
     9  
    10  var Setup = &cobra.Command{
    11  	Use:   "setup",
    12  	Short: "Setup weplanx dynamic configuration",
    13  	RunE: func(cmd *cobra.Command, args []string) (err error) {
    14  		ctx := cmd.Context()
    15  		values := ctx.Value("values").(*common.Values)
    16  
    17  		var x *api.API
    18  		if x, err = bootstrap.NewAPI(values); err != nil {
    19  			return
    20  		}
    21  		if err = x.Values.Service.Update(x.V.Extra); err != nil {
    22  			return
    23  		}
    24  		return
    25  	},
    26  }