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