refactor: clean up NodeService interface; move all integrity logic behind it

This commit is contained in:
2026-03-31 15:55:47 +02:00
parent ed9117951f
commit 8d831d131b
9 changed files with 484 additions and 388 deletions

View File

@@ -21,7 +21,6 @@ func Execute() {
os.Exit(1)
}
registerAliasCommands()
rootCmd.SetArgs(transformArgs(os.Args[1:]))
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
@@ -31,15 +30,6 @@ func init() {
rootCmd.PersistentFlags().BoolVar(&jsonFlag, "json", false, "")
}
func addPropertyFlags(cmd *cobra.Command) {
cmd.Flags().String("type", "", "node type")
cmd.Flags().String("status", "", "node status")
cmd.Flags().String("prio", "", "node priority")
cmd.Flags().String("namespace", "", "node namespace")
cmd.Flags().String("assignee", "", "node assignee")
cmd.Flags().String("mention", "", "node mention")
}
func registerAliasCommands() {
rootCmd.AddGroup(&cobra.Group{ID: "aliases", Title: "Aliases:"})
aliases, _ := cfg.ListAliases()
@@ -70,7 +60,7 @@ func registerAliasCommands() {
}
expanded = append(expanded, replaced)
}
rootCmd.SetArgs(transformArgs(expanded))
rootCmd.SetArgs(expanded)
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
@@ -78,48 +68,3 @@ func registerAliasCommands() {
})
}
}
func transformArgs(args []string) []string {
tagAliases := map[string]string{
"--status": "_status",
"--prio": "_prio",
"--type": "_type",
}
relAliases := map[string]string{
"--namespace": "in_namespace",
"--assignee": "assignee",
"--mention": "mentions",
}
result := []string{}
for i := 0; i < len(args); i++ {
if idx := strings.Index(args[i], "="); idx != -1 {
flag := args[i][:idx]
val := args[i][idx+1:]
if prop, ok := tagAliases[flag]; ok {
result = append(result, "--tag", prop+"::"+val)
continue
}
if prop, ok := relAliases[flag]; ok {
result = append(result, "--rel", prop+":"+val)
continue
}
}
flag := args[i]
if i+1 < len(args) {
if prop, ok := tagAliases[flag]; ok {
result = append(result, "--tag", prop+"::"+args[i+1])
i++
continue
}
if prop, ok := relAliases[flag]; ok {
result = append(result, "--rel", prop+":"+args[i+1])
i++
continue
}
}
result = append(result, args[i])
}
return result
}