MCPcopy
hub / github.com/perkeep/perkeep / RunCommand

Method RunCommand

cmd/pk-put/init.go:202–259  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

200}
201
202func (c *initCmd) RunCommand(args []string) error {
203 if len(args) > 0 {
204 return cmdmain.ErrUsage
205 }
206
207 if c.newKey && c.keyId != "" {
208 log.Fatal("--newkey and --gpgkey are mutually exclusive")
209 }
210
211 if c.userPass != "" {
212 cc, err := c.clientConfigFromServer()
213 if err != nil {
214 return err
215 }
216 return c.writeConfig(cc)
217 }
218
219 var err error
220 if c.newKey {
221 c.secretRing = osutil.DefaultSecretRingFile()
222 c.keyId, err = jsonsign.GenerateNewSecRing(c.secretRing)
223 if err != nil {
224 return err
225 }
226 } else {
227 if err := c.initSecretRing(); err != nil {
228 return err
229 }
230 if err := c.initKeyId(); err != nil {
231 return err
232 }
233 }
234
235 pubArmor, err := c.getPublicKeyArmored()
236 if err != nil {
237 return err
238 }
239
240 bref := blob.RefFromString(string(pubArmor))
241
242 log.Printf("Your Perkeep identity (your GPG public key's blobref) is: %s", bref.String())
243
244 if c.noconfig {
245 return nil
246 }
247
248 return c.writeConfig(&clientconfig.Config{
249 Servers: map[string]*clientconfig.Server{
250 "localhost": {
251 Server: "http://localhost:3179",
252 IsDefault: true,
253 Auth: "localhost",
254 },
255 },
256 Identity: c.keyId,
257 IgnoredFiles: []string{".DS_Store"},
258 })
259}

Callers

nothing calls this directly

Calls 11

writeConfigMethod · 0.95
initSecretRingMethod · 0.95
initKeyIdMethod · 0.95
getPublicKeyArmoredMethod · 0.95
DefaultSecretRingFileFunction · 0.92
GenerateNewSecRingFunction · 0.92
RefFromStringFunction · 0.92
FatalMethod · 0.80
PrintfMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected