forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_db_nuke.go
78 lines (69 loc) · 1.56 KB
/
cmd_db_nuke.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
78
// 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"
"golang.org/x/net/context"
)
type CmdDbNuke struct {
libkb.Contextified
force bool
}
func (c *CmdDbNuke) ParseArgv(ctx *cli.Context) error {
c.force = ctx.Bool("force")
return nil
}
func (c *CmdDbNuke) Run() error {
var err error
if !c.force {
err = GlobUI.PromptForConfirmation("Really blast away your local database?")
}
if err == nil {
cli, err := GetCtlClient(c.G())
if err != nil {
return err
}
if err = RegisterProtocols(nil); err != nil {
return err
}
return cli.DbNuke(context.TODO(), 0)
}
return err
}
func NewCmdDbNuke(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "nuke",
Usage: "Delete the local database",
Action: func(c *cli.Context) {
cl.ChooseCommand(NewCmdDbNukeRunner(g), "nuke", c)
},
Flags: []cli.Flag{
cli.BoolFlag{
Name: "force, f",
Usage: "Don't prompt.",
},
},
}
}
func NewCmdDbNukeRunner(g *libkb.GlobalContext) *CmdDbNuke {
return &CmdDbNuke{
Contextified: libkb.NewContextified(g),
force: false,
}
}
func NewCmdDb(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "db",
Subcommands: []cli.Command{
NewCmdDbNuke(cl, g),
},
}
}
func (c *CmdDbNuke) GetUsage() libkb.Usage {
return libkb.Usage{
Config: true,
API: true,
}
}