MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / runGenerate

Function runGenerate

cmd/cql/internal/generate.go:114–327  ·  view source on GitHub ↗
(cmd *Command, args []string)

Source from the content-addressed store, hash-verified

112}
113
114func 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 }

Callers

nothing calls this directly

Calls 15

HomeDirExpandFunction · 0.92
LoadPrivateKeyFunction · 0.92
GetTestNetConfigFunction · 0.92
SetMinerConfigFunction · 0.92
GenSecp256k1KeyPairFunction · 0.92
SavePrivateKeyFunction · 0.92
PubKeyHashFunction · 0.92
NodeIDTypeAlias · 0.92
commonFlagsInitFunction · 0.85
SetExitStatusFunction · 0.85
readMasterKeyFunction · 0.85
askDeleteFileFunction · 0.85

Tested by

no test coverage detected