refactor: remove db package and move database logic to service layer

This commit is contained in:
2026-03-29 21:24:09 +02:00
parent 6ff013dd2a
commit 4ebcb88628
16 changed files with 163 additions and 217 deletions

View File

@@ -1,7 +1,6 @@
package cmd
import (
"axolotl/db"
"axolotl/output"
"axolotl/service"
"fmt"
@@ -17,12 +16,11 @@ var lMention string
var listCmd = &cobra.Command{
Use: "list", Short: "List nodes",
Run: func(cmd *cobra.Command, args []string) {
d, err := db.GetDB()
svc, err := service.GetNodeService(cfg)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
svc := service.NewSQLiteNodeService(d.DB, cfg.GetUser())
opts := []service.ListOption{}
if len(lTags) > 0 {
opts = append(opts, service.WithTags(lTags...))
@@ -35,7 +33,7 @@ var listCmd = &cobra.Command{
}
if nodes, err := svc.List(opts...); err == nil {
output.PrintNodes(cmd.OutOrStdout(), nodes, jsonFlag)
output.PrintNodes(cmd.OutOrStdout(), svc, nodes, jsonFlag)
} else {
fmt.Fprintf(os.Stderr, "err: %v\n", err)
}