move funcs from cmd/rel.go to cmd/root.go
This commit is contained in:
@@ -1,26 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"axolotl/models"
|
|
||||||
"axolotl/service"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"axolotl/models"
|
||||||
"axolotl/service"
|
"axolotl/service"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user