Files
ax/cmd/inbox.go

40 lines
773 B
Go

package cmd
import (
"axolotl/db"
"axolotl/output"
"axolotl/service"
"fmt"
"os"
"github.com/spf13/cobra"
)
var inboxCmd = &cobra.Command{
Use: "inbox", Short: "Show your inbox",
Run: func(cmd *cobra.Command, args []string) {
d, err := db.GetDB()
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
userID, err := d.GetUserByUsername(cfg.GetUser())
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
if userID == "" {
output.PrintNodes(cmd.OutOrStdout(), nil, jsonFlag)
return
}
svc := service.NewSQLiteNodeService(d.DB, cfg.GetUser())
if nodes, err := svc.List(service.WithMentions(userID)); err == nil {
output.PrintNodes(cmd.OutOrStdout(), nodes, jsonFlag)
}
},
}
func init() {
rootCmd.AddCommand(inboxCmd)
}