test: add e2e test suite and fix namespace/mention/assignee flags

This commit is contained in:
2026-03-29 23:56:43 +02:00
parent dadd3d9e13
commit d569a4dea9
6 changed files with 236 additions and 16 deletions

View File

@@ -36,6 +36,8 @@ func addPropertyFlags(cmd *cobra.Command) {
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() {
@@ -78,24 +80,44 @@ func registerAliasCommands() {
}
func transformArgs(args []string) []string {
aliases := map[string]string{
"--status": "_status",
"--prio": "_prio",
"--type": "_type",
"--namespace": "_namespace",
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 {
if prop, ok := aliases[args[i][:idx]]; ok {
result = append(result, "--tag", prop+"::"+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
}
}
if prop, ok := aliases[args[i]]; ok && i+1 < len(args) {
result, i = append(result, "--tag", prop+"::"+args[i+1]), i+1
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])
}