forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_pgp_update.go
77 lines (67 loc) · 2.02 KB
/
cmd_pgp_update.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
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package client
import (
"github.com/keybase/cli"
"github.com/keybase/client/go/libcmdline"
"github.com/keybase/client/go/libkb"
keybase1 "github.com/keybase/client/go/protocol"
rpc "github.com/keybase/go-framed-msgpack-rpc"
"golang.org/x/net/context"
)
type CmdPGPUpdate struct {
fingerprints []string
all bool
}
func (v *CmdPGPUpdate) ParseArgv(ctx *cli.Context) error {
v.fingerprints = ctx.Args()
v.all = ctx.Bool("all")
return nil
}
func (v *CmdPGPUpdate) Run() (err error) {
cli, err := GetPGPClient()
if err != nil {
return err
}
protocols := []rpc.Protocol{
NewSecretUIProtocol(G),
}
if err = RegisterProtocols(protocols); err != nil {
return err
}
return cli.PGPUpdate(context.TODO(), keybase1.PGPUpdateArg{
Fingerprints: v.fingerprints,
All: v.all,
})
}
func NewCmdPGPUpdate(cl *libcmdline.CommandLine) cli.Command {
return cli.Command{
Name: "update",
ArgumentHelp: "[fingerprints...]",
Usage: "Update your public PGP keys on keybase with those exported from the local GPG keyring",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "all",
Usage: "Update all available keys.",
},
},
Action: func(c *cli.Context) {
cl.ChooseCommand(&CmdPGPUpdate{}, "update", c)
},
Description: `'keybase pgp update' pushes updated PGP public keys to the server.
Public PGP keys are exported from your local GPG keyring and sent
to the Keybase server, where they will supersede PGP keys that have been
previously updated. This feature is for updating PGP subkeys, identities,
and signatures, but cannot be used to change PGP primary keys.
Only keys with the specified PGP fingerprints will be updated, unless the
'--all' flag is specified, in which case all PGP keys will be updated.`,
}
}
func (v *CmdPGPUpdate) GetUsage() libkb.Usage {
return libkb.Usage{
Config: true,
GpgKeyring: true,
KbKeyring: true,
API: true,
}
}