Files
ax/cmd/list.go

53 lines
1.1 KiB
Go
Raw Normal View History

2026-03-26 12:48:47 +00:00
package cmd
import (
"axolotl/db"
"axolotl/output"
2026-03-29 18:58:34 +02:00
"axolotl/service"
2026-03-26 12:48:47 +00:00
"fmt"
"os"
"github.com/spf13/cobra"
)
var lAssignee string
var lTags []string
var lMention string
2026-03-26 12:48:47 +00:00
var listCmd = &cobra.Command{
Use: "list", Short: "List nodes",
2026-03-26 12:48:47 +00:00
Run: func(cmd *cobra.Command, args []string) {
d, err := db.GetDB()
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
2026-03-29 18:58:34 +02:00
svc := service.NewSQLiteNodeService(d.DB, cfg.GetUser())
opts := []service.ListOption{}
if len(lTags) > 0 {
opts = append(opts, service.WithTags(lTags...))
}
if lAssignee != "" {
opts = append(opts, service.WithAssignee(lAssignee))
}
if lMention != "" {
opts = append(opts, service.WithMentions(lMention))
}
if nodes, err := svc.List(opts...); err == nil {
output.PrintNodes(cmd.OutOrStdout(), nodes, jsonFlag)
} else {
fmt.Fprintf(os.Stderr, "err: %v\n", err)
2026-03-26 12:48:47 +00:00
}
},
}
func init() {
rootCmd.AddCommand(listCmd)
addPropertyFlags(listCmd)
f := listCmd.Flags()
f.StringVar(&lAssignee, "assignee", "", "")
f.StringArrayVar(&lTags, "tag", nil, "")
f.StringVar(&lMention, "mention", "", "")
2026-03-26 12:48:47 +00:00
}