github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/client/cmd_pgp_pull.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  	keybase1 "github.com/keybase/client/go/protocol/keybase1"
    11  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
    12  	"golang.org/x/net/context"
    13  )
    14  
    15  type CmdPGPPull struct {
    16  	libkb.Contextified
    17  	userAsserts []string
    18  }
    19  
    20  func (v *CmdPGPPull) ParseArgv(ctx *cli.Context) error {
    21  	v.userAsserts = ctx.Args()
    22  	return nil
    23  }
    24  
    25  func (v *CmdPGPPull) Run() (err error) {
    26  	cli, err := GetPGPClient(v.G())
    27  	if err != nil {
    28  		return err
    29  	}
    30  	protocols := []rpc.Protocol{
    31  		NewIdentifyTrackUIProtocol(v.G()),
    32  	}
    33  	if err = RegisterProtocolsWithContext(protocols, v.G()); err != nil {
    34  		return err
    35  	}
    36  
    37  	return cli.PGPPull(context.TODO(), keybase1.PGPPullArg{
    38  		UserAsserts: v.userAsserts,
    39  	})
    40  }
    41  
    42  func NewCmdPGPPull(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
    43  	return cli.Command{
    44  		Name:         "pull",
    45  		ArgumentHelp: "[<usernames...>]",
    46  		Usage:        "Download the latest PGP keys for people you follow.",
    47  		Flags:        []cli.Flag{},
    48  		Action: func(c *cli.Context) {
    49  			cl.ChooseCommand(&CmdPGPPull{Contextified: libkb.NewContextified(g)}, "pull", c)
    50  		},
    51  		Description: `"keybase pgp pull" pulls down all of the PGP keys for the people
    52     you follow. On success, it imports those keys into your local GnuPG keychain.
    53     For existing keys, this means the local GnuPG keyring will get an updated,
    54     merged copy, via GnuPG's default key merging strategy. For new keys, it
    55     will be a plain import.
    56  
    57     If usernames (or user assertions) are supplied, only those followed users
    58     are pulled. Without arguments, all tracked users are pulled.`,
    59  	}
    60  }
    61  
    62  func (v *CmdPGPPull) GetUsage() libkb.Usage {
    63  	return libkb.Usage{
    64  		Config:     true,
    65  		GpgKeyring: true,
    66  		KbKeyring:  true,
    67  		API:        true,
    68  	}
    69  }