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:
35
cmd/add.go
35
cmd/add.go
@@ -1,6 +1,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"axolotl/models"
|
||||
"axolotl/output"
|
||||
"axolotl/service"
|
||||
"fmt"
|
||||
@@ -9,7 +10,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var cDue, cContent, cStatus, cPrio, cType, cNamespace, cAssignee string
|
||||
var cDue, cContent, cType, cStatus, cPrio, cNamespace, cAssignee string
|
||||
var cTags, cRels []string
|
||||
|
||||
var addCmd = &cobra.Command{
|
||||
@@ -22,15 +23,27 @@ var addCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
input := service.AddInput{
|
||||
Title: args[0],
|
||||
Content: cContent,
|
||||
DueDate: cDue,
|
||||
Type: cType,
|
||||
Status: cStatus,
|
||||
Priority: cPrio,
|
||||
Namespace: cNamespace,
|
||||
Assignee: cAssignee,
|
||||
Tags: cTags,
|
||||
Title: args[0],
|
||||
Content: cContent,
|
||||
DueDate: cDue,
|
||||
Tags: append([]string{}, cTags...),
|
||||
}
|
||||
|
||||
// Shorthand flags expand to tags or rels.
|
||||
if cType != "" {
|
||||
input.Tags = append(input.Tags, "_type::"+cType)
|
||||
}
|
||||
if cStatus != "" {
|
||||
input.Tags = append(input.Tags, "_status::"+cStatus)
|
||||
}
|
||||
if cPrio != "" {
|
||||
input.Tags = append(input.Tags, "_prio::"+cPrio)
|
||||
}
|
||||
if cNamespace != "" {
|
||||
input.Rels = append(input.Rels, service.RelInput{Type: models.RelInNamespace, Target: cNamespace})
|
||||
}
|
||||
if cAssignee != "" {
|
||||
input.Rels = append(input.Rels, service.RelInput{Type: models.RelAssignee, Target: cAssignee})
|
||||
}
|
||||
|
||||
for _, r := range cRels {
|
||||
@@ -55,7 +68,7 @@ var addCmd = &cobra.Command{
|
||||
func init() {
|
||||
rootCmd.AddCommand(addCmd)
|
||||
f := addCmd.Flags()
|
||||
f.StringVar(&cType, "type", "issue", "node type (issue, note, …)")
|
||||
f.StringVar(&cType, "type", "", "node type (issue, note, …)")
|
||||
f.StringVar(&cStatus, "status", "", "initial status (open, done)")
|
||||
f.StringVar(&cPrio, "prio", "", "priority (high, medium, low)")
|
||||
f.StringVar(&cNamespace, "namespace", "", "namespace name or ID")
|
||||
|
||||
Reference in New Issue
Block a user