github.com/iotexproject/iotex-core@v1.14.1-rc1/ioctl/cmd/root.go (about)

     1  // Copyright (c) 2022 IoTeX Foundation
     2  // This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability
     3  // or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed.
     4  // This source code is governed by Apache License 2.0 that can be found in the LICENSE file.
     5  
     6  package cmd
     7  
     8  import (
     9  	"github.com/spf13/cobra"
    10  
    11  	"github.com/iotexproject/iotex-core/ioctl/cmd/account"
    12  	"github.com/iotexproject/iotex-core/ioctl/cmd/action"
    13  	"github.com/iotexproject/iotex-core/ioctl/cmd/alias"
    14  	"github.com/iotexproject/iotex-core/ioctl/cmd/bc"
    15  	"github.com/iotexproject/iotex-core/ioctl/cmd/contract"
    16  	"github.com/iotexproject/iotex-core/ioctl/cmd/did"
    17  	"github.com/iotexproject/iotex-core/ioctl/cmd/hdwallet"
    18  	"github.com/iotexproject/iotex-core/ioctl/cmd/ins"
    19  	"github.com/iotexproject/iotex-core/ioctl/cmd/jwt"
    20  	"github.com/iotexproject/iotex-core/ioctl/cmd/node"
    21  	"github.com/iotexproject/iotex-core/ioctl/cmd/update"
    22  	"github.com/iotexproject/iotex-core/ioctl/cmd/version"
    23  	"github.com/iotexproject/iotex-core/ioctl/cmd/ws"
    24  	"github.com/iotexproject/iotex-core/ioctl/config"
    25  	"github.com/iotexproject/iotex-core/ioctl/output"
    26  )
    27  
    28  // Multi-language support
    29  var (
    30  	_ioctlRootCmdShorts = map[config.Language]string{
    31  		config.English: "Command-line interface for IoTeX blockchain",
    32  		config.Chinese: "IoTeX区块链命令行工具",
    33  	}
    34  	_ioctlRootCmdLongs = map[config.Language]string{
    35  		config.English: `ioctl is a command-line interface for interacting with IoTeX blockchain.`,
    36  		config.Chinese: `ioctl 是用于与IoTeX区块链进行交互的命令行工具`,
    37  	}
    38  	_xctlRootCmdShorts = map[config.Language]string{
    39  		config.English: "Command-line interface for consortium blockchain",
    40  		config.Chinese: "联盟链命令行工具",
    41  	}
    42  	_xctlRootCmdLongs = map[config.Language]string{
    43  		config.English: `xctl is a command-line interface for interacting with consortium blockchain.`,
    44  		config.Chinese: `xctl 是用于与联盟链进行交互的命令行工具`,
    45  	}
    46  	_flagOutputFormatUsages = map[config.Language]string{
    47  		config.English: "output format",
    48  		config.Chinese: "指定输出格式",
    49  	}
    50  )
    51  
    52  // NewIoctl returns ioctl root cmd
    53  func NewIoctl() *cobra.Command {
    54  	var rootCmd = &cobra.Command{
    55  		Use:   "ioctl",
    56  		Short: config.TranslateInLang(_ioctlRootCmdShorts, config.UILanguage),
    57  		Long:  config.TranslateInLang(_ioctlRootCmdLongs, config.UILanguage),
    58  	}
    59  
    60  	rootCmd.AddCommand(config.ConfigCmd)
    61  	rootCmd.AddCommand(account.AccountCmd)
    62  	rootCmd.AddCommand(alias.AliasCmd)
    63  	rootCmd.AddCommand(action.ActionCmd)
    64  	rootCmd.AddCommand(action.Xrc20Cmd)
    65  	rootCmd.AddCommand(action.Stake2Cmd)
    66  	rootCmd.AddCommand(bc.BCCmd)
    67  	rootCmd.AddCommand(node.NodeCmd)
    68  	rootCmd.AddCommand(version.VersionCmd)
    69  	rootCmd.AddCommand(update.UpdateCmd)
    70  	rootCmd.AddCommand(contract.ContractCmd)
    71  	rootCmd.AddCommand(did.DIDCmd)
    72  	rootCmd.AddCommand(hdwallet.HdwalletCmd)
    73  	rootCmd.AddCommand(jwt.JwtCmd)
    74  	rootCmd.AddCommand(ins.InsCmd)
    75  	rootCmd.AddCommand(ws.WsCmd)
    76  	rootCmd.PersistentFlags().StringVarP(&output.Format, "output-format", "o", "",
    77  		config.TranslateInLang(_flagOutputFormatUsages, config.UILanguage))
    78  
    79  	return rootCmd
    80  }
    81  
    82  // NewXctl returns xctl root cmd
    83  func NewXctl() *cobra.Command {
    84  	var rootCmd = &cobra.Command{
    85  		Use:   "xctl",
    86  		Short: config.TranslateInLang(_xctlRootCmdShorts, config.UILanguage),
    87  		Long:  config.TranslateInLang(_xctlRootCmdLongs, config.UILanguage),
    88  	}
    89  
    90  	rootCmd.AddCommand(config.ConfigCmd)
    91  	rootCmd.AddCommand(account.AccountCmd)
    92  	rootCmd.AddCommand(alias.AliasCmd)
    93  	rootCmd.AddCommand(action.ActionCmd)
    94  	rootCmd.AddCommand(action.Xrc20Cmd)
    95  	rootCmd.AddCommand(bc.BCCmd)
    96  	rootCmd.AddCommand(version.VersionCmd)
    97  	rootCmd.AddCommand(contract.ContractCmd)
    98  	// TODO: add xctl's UpdateCmd
    99  
   100  	rootCmd.PersistentFlags().StringVarP(&output.Format, "output-format", "o", "",
   101  		config.TranslateInLang(_flagOutputFormatUsages, config.UILanguage))
   102  
   103  	return rootCmd
   104  }