-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Surya/core 9183/additional imptofu rpcs (#14910)
Surya/core 9183/additional imptofu rpcs (#14910)
- Loading branch information
Showing
47 changed files
with
2,166 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2018 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" | ||
) | ||
|
||
func NewCmdEmail(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { | ||
return cli.Command{ | ||
Name: "email", | ||
Usage: "Manage your emails", | ||
Subcommands: []cli.Command{ | ||
NewCmdAddEmail(cl, g), | ||
NewCmdEditEmail(cl, g), | ||
NewCmdDeleteEmail(cl, g), | ||
NewCmdListEmails(cl, g), | ||
NewCmdSetVisibilityEmail(cl, g), | ||
NewCmdSetPrimaryEmail(cl, g), | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2018 Keybase, Inc. All rights reserved. Use of | ||
// this source code is governed by the included BSD license. | ||
|
||
package client | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/keybase/cli" | ||
"github.com/keybase/client/go/libcmdline" | ||
"github.com/keybase/client/go/libkb" | ||
"github.com/keybase/client/go/protocol/keybase1" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
type CmdAddEmail struct { | ||
libkb.Contextified | ||
Email string | ||
Visibility keybase1.IdentityVisibility | ||
} | ||
|
||
func NewCmdAddEmail(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { | ||
cmd := &CmdAddEmail{ | ||
Contextified: libkb.NewContextified(g), | ||
} | ||
return cli.Command{ | ||
Name: "add", | ||
Usage: "Add email to your Keybase account", | ||
ArgumentHelp: "<email> <private|public>", | ||
Action: func(c *cli.Context) { | ||
cl.ChooseCommand(cmd, "add", c) | ||
}, | ||
} | ||
} | ||
|
||
func (c *CmdAddEmail) ParseArgv(ctx *cli.Context) error { | ||
if len(ctx.Args()) != 2 { | ||
return errors.New("invalid number of arguments.") | ||
} | ||
c.Email = ctx.Args()[0] | ||
visibility, ok := keybase1.IdentityVisibilityMap[strings.ToUpper(ctx.Args()[1])] | ||
if !ok { | ||
return fmt.Errorf("Unknown identity visibility: %s", visibility) | ||
} | ||
c.Visibility = visibility | ||
return nil | ||
} | ||
|
||
func (c *CmdAddEmail) Run() error { | ||
cli, err := GetEmailsClient(c.G()) | ||
if err != nil { | ||
return err | ||
} | ||
arg := keybase1.AddEmailArg{ | ||
Email: keybase1.EmailAddress(c.Email), | ||
Visibility: c.Visibility, | ||
} | ||
err = cli.AddEmail(context.Background(), arg) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println("A verification code has been sent to your email.") | ||
return nil | ||
} | ||
|
||
func (c *CmdAddEmail) GetUsage() libkb.Usage { | ||
return libkb.Usage{ | ||
Config: true, | ||
API: true, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2018 Keybase, Inc. All rights reserved. Use of | ||
// this source code is governed by the included BSD license. | ||
|
||
package client | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/keybase/cli" | ||
"github.com/keybase/client/go/libcmdline" | ||
"github.com/keybase/client/go/libkb" | ||
"github.com/keybase/client/go/protocol/keybase1" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
type CmdDeleteEmail struct { | ||
libkb.Contextified | ||
Email string | ||
} | ||
|
||
func NewCmdDeleteEmail(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { | ||
cmd := &CmdDeleteEmail{ | ||
Contextified: libkb.NewContextified(g), | ||
} | ||
return cli.Command{ | ||
Name: "delete", | ||
Usage: "Delete email from your Keybase account", | ||
ArgumentHelp: "<email>", | ||
Action: func(c *cli.Context) { | ||
cl.ChooseCommand(cmd, "delete", c) | ||
}, | ||
} | ||
} | ||
|
||
func (c *CmdDeleteEmail) ParseArgv(ctx *cli.Context) error { | ||
if len(ctx.Args()) != 1 { | ||
return errors.New("invalid number of arguments.") | ||
} | ||
c.Email = ctx.Args()[0] | ||
return nil | ||
} | ||
|
||
func (c *CmdDeleteEmail) Run() error { | ||
cli, err := GetEmailsClient(c.G()) | ||
if err != nil { | ||
return err | ||
} | ||
arg := keybase1.DeleteEmailArg{ | ||
Email: keybase1.EmailAddress(c.Email), | ||
} | ||
return cli.DeleteEmail(context.Background(), arg) | ||
} | ||
|
||
func (c *CmdDeleteEmail) GetUsage() libkb.Usage { | ||
return libkb.Usage{ | ||
Config: true, | ||
API: true, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright 2018 Keybase, Inc. All rights reserved. Use of | ||
// this source code is governed by the included BSD license. | ||
|
||
package client | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/keybase/cli" | ||
"github.com/keybase/client/go/libcmdline" | ||
"github.com/keybase/client/go/libkb" | ||
"github.com/keybase/client/go/protocol/keybase1" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
type CmdEditEmail struct { | ||
libkb.Contextified | ||
OldEmail string | ||
Email string | ||
Visibility keybase1.IdentityVisibility | ||
} | ||
|
||
func NewCmdEditEmail(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { | ||
cmd := &CmdEditEmail{ | ||
Contextified: libkb.NewContextified(g), | ||
} | ||
return cli.Command{ | ||
Name: "edit", | ||
Usage: "Edit a email", | ||
ArgumentHelp: "<old email> <new email> <private|public (visibility for new email)>", | ||
Action: func(c *cli.Context) { | ||
cl.ChooseCommand(cmd, "edit", c) | ||
}, | ||
} | ||
} | ||
|
||
func (c *CmdEditEmail) ParseArgv(ctx *cli.Context) error { | ||
if len(ctx.Args()) != 3 { | ||
return errors.New("invalid number of arguments.") | ||
} | ||
c.OldEmail = ctx.Args()[0] | ||
c.Email = ctx.Args()[1] | ||
visibility, ok := keybase1.IdentityVisibilityMap[strings.ToUpper(ctx.Args()[2])] | ||
if !ok { | ||
return fmt.Errorf("Unknown identity visibility: %s", visibility) | ||
} | ||
c.Visibility = visibility | ||
return nil | ||
} | ||
|
||
func (c *CmdEditEmail) Run() error { | ||
cli, err := GetEmailsClient(c.G()) | ||
if err != nil { | ||
return err | ||
} | ||
arg := keybase1.EditEmailArg{ | ||
OldEmail: keybase1.EmailAddress(c.OldEmail), | ||
Email: keybase1.EmailAddress(c.Email), | ||
Visibility: c.Visibility, | ||
} | ||
err = cli.EditEmail(context.Background(), arg) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println("A verification code has been sent to your email.`") | ||
return nil | ||
} | ||
|
||
func (c *CmdEditEmail) GetUsage() libkb.Usage { | ||
return libkb.Usage{ | ||
Config: true, | ||
API: true, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright 2018 Keybase, Inc. All rights reserved. Use of | ||
// this source code is governed by the included BSD license. | ||
|
||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
"errors" | ||
|
||
"github.com/keybase/cli" | ||
"github.com/keybase/client/go/libcmdline" | ||
"github.com/keybase/client/go/libkb" | ||
"github.com/keybase/client/go/protocol/keybase1" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
type CmdListEmails struct { | ||
libkb.Contextified | ||
json bool | ||
} | ||
|
||
func NewCmdListEmails(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { | ||
cmd := &CmdListEmails{ | ||
Contextified: libkb.NewContextified(g), | ||
} | ||
return cli.Command{ | ||
Name: "list", | ||
Usage: "List emails attached to your account", | ||
Flags: []cli.Flag{ | ||
cli.BoolFlag{ | ||
Name: "j, json", | ||
Usage: "Output as JSON", | ||
}, | ||
}, | ||
Action: func(c *cli.Context) { | ||
cl.ChooseCommand(cmd, "list", c) | ||
}, | ||
} | ||
} | ||
|
||
func (c *CmdListEmails) ParseArgv(ctx *cli.Context) error { | ||
if len(ctx.Args()) != 0 { | ||
return errors.New("invalid number of arguments.") | ||
} | ||
c.json = ctx.Bool("json") | ||
return nil | ||
} | ||
|
||
func (c *CmdListEmails) Run() error { | ||
cli, err := GetEmailsClient(c.G()) | ||
if err != nil { | ||
return err | ||
} | ||
resp, err := cli.GetEmails(context.Background(), 0) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
ui := c.G().UI.GetTerminalUI() | ||
if c.json { | ||
b, err := json.Marshal(resp) | ||
if err != nil { | ||
return err | ||
} | ||
ui.Printf("%s\n", string(b)) | ||
return nil | ||
} | ||
|
||
for _, p := range resp { | ||
visibilityName := keybase1.IdentityVisibilityRevMap[p.Visibility] | ||
ui.Printf("%s (visibility: %s, verified: %t, primary: %t)\n", p.Email, | ||
visibilityName, p.IsVerified, p.IsPrimary) | ||
} | ||
return nil | ||
} | ||
|
||
func (c *CmdListEmails) GetUsage() libkb.Usage { | ||
return libkb.Usage{ | ||
Config: true, | ||
API: true, | ||
} | ||
} |
Oops, something went wrong.