This commit is contained in:
Benjamin A. Shelton 2026-10-20 20:17:29 -06:00
commit 58a01bff56
Signed by: zancarius
GPG key ID: 8BD42DBD6C337E01
5 changed files with 99 additions and 26 deletions

View file

@ -43,3 +43,28 @@ func (c *chats) AddChat(ctx context.Context, cmd *cli.Command) error {
return nil
}
func (c *chats) ListChats(ctx context.Context, cmd *cli.Command) error {
logger := logging.Get("commands")
logger.SetFormat("chat add: {{message}}")
mdb := models.OpenDatabase(ctx, c.settings)
if err := mdb.Open(); err != nil {
logger.Error("connection error:", errors.Unfurl(err))
return err
}
mdl := models.NewChatModel(ctx, mdb.DB())
chats, err := mdl.ListChats()
if err != nil {
if errors.Is(err, models.ErrNoRows) {
logger.Error("no chats configured")
return nil
}
return err
}
for i, chat := range chats {
fmt.Printf("%d: %s <%d>\n", i, chat.Name, chat.ID)
}
return nil
}

View file

@ -33,6 +33,7 @@ func NewCommandHost(ctx context.Context, root vfs.VFS) (*commands, error) {
}
cmd := &commands{
ctx: ctx,
root: root,
settings: conf,
}