refactor: clean up NodeService interface; move all integrity logic behind it
This commit is contained in:
19
cmd/edit.go
19
cmd/edit.go
@@ -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)
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user