-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
cmd_chat_archive_delete.go
81 lines (69 loc) · 1.86 KB
/
cmd_chat_archive_delete.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
79
80
81
package client
import (
"fmt"
"github.com/keybase/cli"
"github.com/keybase/client/go/libcmdline"
"github.com/keybase/client/go/libkb"
"github.com/keybase/client/go/protocol/chat1"
"github.com/keybase/client/go/protocol/keybase1"
"golang.org/x/net/context"
)
type CmdChatArchiveDelete struct {
libkb.Contextified
jobID chat1.ArchiveJobID
deleteOutputPath bool
}
func NewCmdChatArchiveDeleteRunner(g *libkb.GlobalContext) *CmdChatArchiveDelete {
return &CmdChatArchiveDelete{
Contextified: libkb.NewContextified(g),
}
}
func newCmdChatArchiveDelete(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "archive-delete",
Usage: "Clear the metadata of an archive job",
ArgumentHelp: "job-id",
Action: func(c *cli.Context) {
cl.ChooseCommand(NewCmdChatArchiveDeleteRunner(g), "archive-delete", c)
cl.SetLogForward(libcmdline.LogForwardNone)
},
Flags: []cli.Flag{
cli.BoolFlag{
Name: "delete-output-path",
Usage: "Delete the locally archived data",
},
},
}
}
func (c *CmdChatArchiveDelete) Run() error {
client, err := GetChatLocalClient(c.G())
if err != nil {
return err
}
arg := chat1.ArchiveChatDeleteArg{
JobID: c.jobID,
DeleteOutputPath: c.deleteOutputPath,
IdentifyBehavior: keybase1.TLFIdentifyBehavior_CHAT_CLI,
}
err = client.ArchiveChatDelete(context.TODO(), arg)
if err != nil {
return err
}
ui := c.G().UI.GetTerminalUI()
ui.Printf("Job deleted\n")
return nil
}
func (c *CmdChatArchiveDelete) ParseArgv(ctx *cli.Context) (err error) {
if len(ctx.Args()) != 1 {
return fmt.Errorf("job-id is required")
}
c.jobID = chat1.ArchiveJobID(ctx.Args().Get(0))
c.deleteOutputPath = ctx.Bool("delete-output-path")
return nil
}
func (c *CmdChatArchiveDelete) GetUsage() libkb.Usage {
return libkb.Usage{
Config: true,
API: true,
}
}