Files
ax/cmd/list.go
Elias Kohout a04750dd15 refactor: simplify db and cmd flags, reduce code duplication
- Abstract property flags into addPropertyFlags in cmd/root.go and apply to commands
- Remove unused GetUserByUsername from db.go (it's redundant with service.resolveUserIDByName)
- Use configured user in WithMentions directly in inbox command
- Refactor resolve methods in node_service_sqlite.go to reduce duplication
2026-03-29 19:22:44 +02:00

40 lines
823 B
Go

package cmd
import (
"axolotl/db"
"axolotl/output"
"axolotl/service"
"fmt"
"os"
"github.com/spf13/cobra"
)
var lAssignee string
var lTags []string
var listCmd = &cobra.Command{
Use: "list", Short: "List nodes",
Run: func(cmd *cobra.Command, args []string) {
d, err := db.GetDB()
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
svc := service.NewSQLiteNodeService(d.DB, cfg.GetUser())
if nodes, err := svc.List(service.WithTags(lTags...), service.WithAssignee(lAssignee)); err == nil {
output.PrintNodes(cmd.OutOrStdout(), nodes, jsonFlag)
} else {
fmt.Fprintf(os.Stderr, "err: %v\n", err)
}
},
}
func init() {
rootCmd.AddCommand(listCmd)
addPropertyFlags(listCmd)
f := listCmd.Flags()
f.StringVar(&lAssignee, "assignee", "", "")
f.StringArrayVar(&lTags, "tag", nil, "")
}