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"
"bufio"
@@ -16,12 +15,11 @@ var dForce bool
var delCmd = &cobra.Command{
Use: "del <id>", Short: "Delete a node", 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)
fmt.Fprintln(os.Stderr, "failed to create service: %v", err)
return
}
svc := service.NewSQLiteNodeService(d.DB, cfg.GetUser())
n, err := svc.GetByID(args[0])
if err != nil {
fmt.Fprintln(os.Stderr, " node not found:", args[0])