github.com/turingchain2020/turingchain@v1.1.21/cmd/tools/gencode/dappcode/commands/commands.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  	"github.com/turingchain2020/turingchain/cmd/tools/gencode/base"
     9  	"github.com/turingchain2020/turingchain/cmd/tools/types"
    10  )
    11  
    12  func init() {
    13  
    14  	base.RegisterCodeFile(commandsCodeFile{})
    15  }
    16  
    17  type commandsCodeFile struct {
    18  	base.DappCodeFile
    19  }
    20  
    21  func (c commandsCodeFile) GetDirName() string {
    22  
    23  	return "commands"
    24  }
    25  
    26  func (c commandsCodeFile) GetFiles() map[string]string {
    27  
    28  	return map[string]string{
    29  		commandsFileName: commandsFileContent,
    30  	}
    31  }
    32  
    33  func (c commandsCodeFile) GetFileReplaceTags() []string {
    34  	return []string{types.TagExecName}
    35  }
    36  
    37  var (
    38  	commandsFileName    = "commands.go"
    39  	commandsFileContent = `/*Package commands implement dapp client commands*/
    40  package commands
    41  
    42  import (
    43  	"github.com/spf13/cobra"
    44  )
    45  
    46  /* 
    47   * 实现合约对应客户端
    48  */
    49  
    50  // Cmd ${EXECNAME} client command
    51  func Cmd() *cobra.Command {
    52  	cmd := &cobra.Command{
    53  		Use:	"${EXECNAME}",
    54  		Short:	"${EXECNAME} command",
    55  		Args:	cobra.MinimumNArgs(1),
    56  	}
    57  	cmd.AddCommand(
    58  		//add sub command
    59  	)
    60  	return cmd
    61  }
    62  `
    63  )