refactor: clean up NodeService interface; move all integrity logic behind it

This commit is contained in:
2026-03-31 15:55:47 +02:00
parent ed9117951f
commit 8d831d131b
9 changed files with 484 additions and 388 deletions

View File

@@ -45,17 +45,18 @@ var editCmd = &cobra.Command{
return
}
if content, err := os.ReadFile(tmp.Name()); err == nil {
n.Content = string(content)
if err := svc.Update(n); err != nil {
fmt.Fprintln(os.Stderr, "failed to update:", err)
return
}
n, _ = svc.GetByID(args[0])
output.PrintNode(cmd.OutOrStdout(), svc, n, jsonFlag)
} else {
content, err := os.ReadFile(tmp.Name())
if err != nil {
fmt.Fprintln(os.Stderr, "failed to read temp file:", err)
return
}
s := string(content)
n, err = svc.Update(args[0], service.UpdateInput{Content: &s})
if err != nil {
fmt.Fprintln(os.Stderr, "failed to update:", err)
return
}
output.PrintNode(cmd.OutOrStdout(), svc, n, jsonFlag)
},
}