github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/client/cmd_paperkey.go (about) 1 // Copyright 2015 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 package client 5 6 import ( 7 "github.com/keybase/cli" 8 "github.com/keybase/client/go/libcmdline" 9 "github.com/keybase/client/go/libkb" 10 "github.com/keybase/go-framed-msgpack-rpc/rpc" 11 "golang.org/x/net/context" 12 ) 13 14 func NewCmdPaperKey(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { 15 return cli.Command{ 16 Name: "paperkey", 17 Usage: "Generate paper keys for recovering your account", 18 Action: func(c *cli.Context) { 19 cl.ChooseCommand(NewCmdPaperKeyRunner(g), "paperkey", c) 20 }, 21 } 22 } 23 24 type CmdPaperKey struct { 25 libkb.Contextified 26 } 27 28 func NewCmdPaperKeyRunner(g *libkb.GlobalContext) *CmdPaperKey { 29 return &CmdPaperKey{ 30 Contextified: libkb.NewContextified(g), 31 } 32 } 33 34 func (c *CmdPaperKey) Run() error { 35 cli, err := GetLoginClient(c.G()) 36 if err != nil { 37 return err 38 } 39 protocols := []rpc.Protocol{ 40 NewLoginUIProtocol(c.G()), 41 NewSecretUIProtocol(c.G()), 42 } 43 if err := RegisterProtocolsWithContext(protocols, c.G()); err != nil { 44 return err 45 } 46 return cli.PaperKey(context.TODO(), 0) 47 } 48 49 func (c *CmdPaperKey) ParseArgv(ctx *cli.Context) error { 50 return nil 51 } 52 53 func (c *CmdPaperKey) GetUsage() libkb.Usage { 54 return libkb.Usage{ 55 Config: true, 56 API: true, 57 KbKeyring: true, 58 } 59 }