(cmd *Command, args []string)
| 112 | } |
| 113 | |
| 114 | func runGenerate(cmd *Command, args []string) { |
| 115 | commonFlagsInit(cmd) |
| 116 | |
| 117 | var workingRoot string |
| 118 | if len(args) == 0 { |
| 119 | workingRoot = utils.HomeDirExpand("~/.cql") |
| 120 | } else if args[0] == "" { |
| 121 | workingRoot = utils.HomeDirExpand("~/.cql") |
| 122 | } else { |
| 123 | workingRoot = utils.HomeDirExpand(args[0]) |
| 124 | } |
| 125 | |
| 126 | if workingRoot == "" { |
| 127 | ConsoleLog.Error("config directory is required for generate config") |
| 128 | SetExitStatus(1) |
| 129 | return |
| 130 | } |
| 131 | |
| 132 | if strings.HasSuffix(workingRoot, "config.yaml") { |
| 133 | workingRoot = filepath.Dir(workingRoot) |
| 134 | } |
| 135 | |
| 136 | privateKeyFileName := "private.key" |
| 137 | privateKeyFile := path.Join(workingRoot, privateKeyFileName) |
| 138 | |
| 139 | var ( |
| 140 | privateKey *asymmetric.PrivateKey |
| 141 | err error |
| 142 | ) |
| 143 | |
| 144 | // detect customized private key |
| 145 | if privateKeyParam != "" { |
| 146 | var oldPassword string |
| 147 | |
| 148 | if password == "" { |
| 149 | fmt.Println("Please enter the passphrase of the existing private key") |
| 150 | oldPassword = readMasterKey(!withPassword) |
| 151 | } else { |
| 152 | oldPassword = password |
| 153 | } |
| 154 | |
| 155 | privateKey, err = kms.LoadPrivateKey(privateKeyParam, []byte(oldPassword)) |
| 156 | |
| 157 | if err != nil { |
| 158 | ConsoleLog.WithError(err).Error("load specified private key failed") |
| 159 | SetExitStatus(1) |
| 160 | return |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | var port string |
| 165 | if minerListenAddr != "" { |
| 166 | minerListenAddrSplit := strings.Split(minerListenAddr, ":") |
| 167 | if len(minerListenAddrSplit) != 2 { |
| 168 | ConsoleLog.Error("-miner only accepts listen address in ip:port format. e.g. 127.0.0.1:7458") |
| 169 | SetExitStatus(1) |
| 170 | return |
| 171 | } |
nothing calls this directly
no test coverage detected