move funcs from cmd/rel.go to cmd/root.go

This commit is contained in:
2026-04-01 22:39:44 +02:00
parent 706baf81aa
commit 2bcc310c6d
2 changed files with 20 additions and 26 deletions

View File

@@ -1,6 +1,7 @@
package cmd
import (
"axolotl/models"
"axolotl/service"
"fmt"
"os"
@@ -84,3 +85,22 @@ func registerAliasCommands() {
})
}
}
// parseRelInput parses a rel string into a RelInput.
//
// Formats:
// - "prefix::value" → property rel with no target (tag)
// - "relname:target" → edge rel with a target node
// - "tagname" → simple label rel with no target (alias for --tag)
func parseRelInput(s string) (service.RelInput, error) {
if strings.Contains(s, "::") {
// Property: name::value — no target node.
return service.RelInput{Type: models.RelType(s), Target: ""}, nil
}
if idx := strings.Index(s, ":"); idx >= 0 {
// Edge rel: relname:target.
return service.RelInput{Type: models.RelType(s[:idx]), Target: s[idx+1:]}, nil
}
// Simple label tag — no target node.
return service.RelInput{Type: models.RelType(s), Target: ""}, nil
}