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"
@@ -13,14 +12,13 @@ import (
var showCmd = &cobra.Command{
Use: "show <id>", Short: "Show node details", Args: cobra.ExactArgs(1),
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())
if n, err := svc.GetByID(args[0]); err == nil {
output.PrintNode(cmd.OutOrStdout(), n, jsonFlag)
output.PrintNode(cmd.OutOrStdout(), svc, n, jsonFlag)
} else {
fmt.Fprintln(os.Stderr, "node not found:", args[0])
}