refactor: simplify service interface to use tags/rels for all node properties

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-31 23:10:56 +02:00
parent 4404518f50
commit cb16bda200
5 changed files with 151 additions and 147 deletions

View File

@@ -1,6 +1,7 @@
package cmd
import (
"axolotl/models"
"axolotl/output"
"axolotl/service"
"fmt"
@@ -10,10 +11,11 @@ import (
)
var (
uTitle, uContent, uDue string
uClearDue bool
uStatus, uPrio, uType, uNamespace, uAssignee string
uAddTags, uRmTags, uAddRels, uRmRels []string
uTitle, uContent, uDue string
uClearDue bool
uStatus, uPrio, uType string
uNamespace, uAssignee string
uAddTags, uRmTags, uAddRels, uRmRels []string
)
var updateCmd = &cobra.Command{
@@ -26,7 +28,7 @@ var updateCmd = &cobra.Command{
}
input := service.UpdateInput{
AddTags: uAddTags,
AddTags: append([]string{}, uAddTags...),
RemoveTags: uRmTags,
}
@@ -43,20 +45,22 @@ var updateCmd = &cobra.Command{
empty := ""
input.DueDate = &empty
}
// Shorthand flags expand to tags or rels.
if cmd.Flags().Changed("type") {
input.AddTags = append(input.AddTags, "_type::"+uType)
}
if cmd.Flags().Changed("status") {
input.Status = &uStatus
input.AddTags = append(input.AddTags, "_status::"+uStatus)
}
if cmd.Flags().Changed("prio") {
input.Priority = &uPrio
}
if cmd.Flags().Changed("type") {
input.Type = &uType
input.AddTags = append(input.AddTags, "_prio::"+uPrio)
}
if cmd.Flags().Changed("namespace") {
input.Namespace = &uNamespace
input.AddRels = append(input.AddRels, service.RelInput{Type: models.RelInNamespace, Target: uNamespace})
}
if cmd.Flags().Changed("assignee") {
input.Assignee = &uAssignee
input.AddRels = append(input.AddRels, service.RelInput{Type: models.RelAssignee, Target: uAssignee})
}
for _, r := range uAddRels {