github.com/iotexproject/iotex-core@v1.14.1-rc1/ioctl/newcmd/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 newcmd
     7  
     8  import (
     9  	"github.com/spf13/cobra"
    10  
    11  	"github.com/iotexproject/iotex-core/ioctl"
    12  	"github.com/iotexproject/iotex-core/ioctl/config"
    13  	"github.com/iotexproject/iotex-core/ioctl/newcmd/account"
    14  	"github.com/iotexproject/iotex-core/ioctl/newcmd/bc"
    15  	"github.com/iotexproject/iotex-core/ioctl/newcmd/node"
    16  )
    17  
    18  // Multi-language support
    19  var (
    20  	_ioctlRootCmdShorts = map[config.Language]string{
    21  		config.English: "Command-line interface for IoTeX blockchain",
    22  		config.Chinese: "IoTeX区块链命令行工具",
    23  	}
    24  	_ioctlRootCmdLongs = map[config.Language]string{
    25  		config.English: `ioctl is a command-line interface for interacting with IoTeX blockchain.`,
    26  		config.Chinese: `ioctl 是用于与IoTeX区块链进行交互的命令行工具`,
    27  	}
    28  	_xctlRootCmdShorts = map[config.Language]string{
    29  		config.English: "Command-line interface for consortium blockchain",
    30  		config.Chinese: "联盟链命令行工具",
    31  	}
    32  	_xctlRootCmdLongs = map[config.Language]string{
    33  		config.English: `xctl is a command-line interface for interacting with consortium blockchain.`,
    34  		config.Chinese: `xctl 是用于与联盟链进行交互的命令行工具`,
    35  	}
    36  )
    37  
    38  // NewIoctl returns ioctl root cmd
    39  func NewIoctl(client ioctl.Client) *cobra.Command {
    40  	rootShorts, _ := client.SelectTranslation(_ioctlRootCmdShorts)
    41  	rootLongs, _ := client.SelectTranslation(_ioctlRootCmdLongs)
    42  
    43  	rootCmd := &cobra.Command{
    44  		Use:   "ioctl",
    45  		Short: rootShorts,
    46  		Long:  rootLongs,
    47  	}
    48  
    49  	rootCmd.AddCommand(config.ConfigCmd)
    50  	rootCmd.AddCommand(account.NewAccountCmd(client))
    51  	rootCmd.AddCommand(bc.NewBCCmd(client))
    52  	rootCmd.AddCommand(node.NewNodeCmd(client))
    53  
    54  	return rootCmd
    55  }
    56  
    57  // NewXctl returns xctl root cmd
    58  func NewXctl(client ioctl.Client) *cobra.Command {
    59  	rootShorts, _ := client.SelectTranslation(_xctlRootCmdShorts)
    60  	rootLongs, _ := client.SelectTranslation(_xctlRootCmdLongs)
    61  
    62  	var rootCmd = &cobra.Command{
    63  		Use:   "xctl",
    64  		Short: rootShorts,
    65  		Long:  rootLongs,
    66  	}
    67  
    68  	rootCmd.AddCommand(config.ConfigCmd)
    69  	rootCmd.AddCommand(account.NewAccountCmd(client))
    70  
    71  	return rootCmd
    72  }