github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/client/cmd_chat_list.go (about) 1 // Copyright 2016 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 "golang.org/x/net/context" 8 9 "github.com/keybase/cli" 10 "github.com/keybase/client/go/chatrender" 11 "github.com/keybase/client/go/libcmdline" 12 "github.com/keybase/client/go/libkb" 13 ) 14 15 type cmdChatList struct { 16 libkb.Contextified 17 fetcher chatCLIInboxFetcher 18 showDeviceName bool 19 } 20 21 func newCmdChatList(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command { 22 return cli.Command{ 23 Name: "list", 24 Usage: "List conversations, sorted by activity.", 25 Aliases: []string{"ls"}, 26 ArgumentHelp: "", 27 Action: func(c *cli.Context) { 28 cl.ChooseCommand(&cmdChatList{Contextified: libkb.NewContextified(g)}, "list", c) 29 cl.SetNoStandalone() 30 cl.SetLogForward(libcmdline.LogForwardNone) 31 }, 32 Flags: getInboxFetcherActivitySortedFlags(), 33 } 34 } 35 36 func (c *cmdChatList) Run() error { 37 conversations, err := c.fetcher.fetch(context.TODO(), c.G()) 38 if err != nil { 39 return err 40 } 41 42 if err = chatrender.ConversationListView(conversations).Show(c.G(), c.G().Env.GetUsername().String(), 43 c.showDeviceName); err != nil { 44 return err 45 } 46 47 // TODO: print summary of inbox. e.g. 48 // +44 older chats (--time=7d to see 25 more) 49 50 return nil 51 } 52 53 func (c *cmdChatList) ParseArgv(ctx *cli.Context) (err error) { 54 if c.fetcher, err = makeChatCLIInboxFetcherActivitySorted(ctx); err != nil { 55 return err 56 } 57 c.showDeviceName = ctx.Bool("show-device-name") 58 return nil 59 } 60 61 func (c *cmdChatList) GetUsage() libkb.Usage { 62 return libkb.Usage{ 63 Config: true, 64 API: true, 65 } 66 }