github.com/turingchain2020/turingchain@v1.1.21/cmd/tools/commands/updateinit.go (about)

     1  // Copyright Turing Corp. 2018 All Rights Reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package commands
     6  
     7  import (
     8  	"fmt"
     9  
    10  	"github.com/turingchain2020/turingchain/cmd/tools/strategy"
    11  	"github.com/turingchain2020/turingchain/cmd/tools/types"
    12  	"github.com/spf13/cobra"
    13  )
    14  
    15  //UpdateInitCmd 升级初始命令
    16  func UpdateInitCmd() *cobra.Command {
    17  	cmd := &cobra.Command{
    18  		Use:   "updateinit",
    19  		Short: "Update turingchain plugin consensus、dapp、store、mempool init.go file",
    20  		Run:   updateInit,
    21  	}
    22  	cmd.Flags().StringP("path", "p", "plugin", "path of plugin")
    23  	cmd.Flags().StringP("out", "o", "", "output new config file")
    24  	cmd.Flags().StringP("packname", "", "", "project package name")
    25  	return cmd
    26  }
    27  
    28  func updateInit(cmd *cobra.Command, args []string) {
    29  	path, _ := cmd.Flags().GetString("path")
    30  	packname, _ := cmd.Flags().GetString("packname")
    31  	out, _ := cmd.Flags().GetString("out")
    32  
    33  	s := strategy.New(types.KeyUpdateInit)
    34  	if s == nil {
    35  		fmt.Println(types.KeyUpdateInit, "Not support")
    36  		return
    37  	}
    38  	s.SetParam("out", out)
    39  	s.SetParam("path", path)
    40  	s.SetParam("packname", packname)
    41  	s.Run()
    42  }