test: add e2e test suite and fix namespace/mention/assignee flags
This commit is contained in:
@@ -24,8 +24,8 @@ var addCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
// default relations
|
||||
if !slices.ContainsFunc(cRels, func(e string) bool { return strings.HasPrefix(e, "_namespace::") }) {
|
||||
cRels = append(cRels, "_namespace::"+cfg.GetUser())
|
||||
if !slices.ContainsFunc(cRels, func(e string) bool { return strings.HasPrefix(e, "in_namespace:") }) {
|
||||
cRels = append(cRels, "in_namespace:"+cfg.GetUser())
|
||||
}
|
||||
|
||||
// parse relations
|
||||
|
||||
42
cmd/root.go
42
cmd/root.go
@@ -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])
|
||||
}
|
||||
|
||||
@@ -55,11 +55,11 @@ var updateCmd = &cobra.Command{
|
||||
ok, blockers, err := svc.CanClose(args[0])
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "failed to check blockers:", err)
|
||||
return
|
||||
os.Exit(1)
|
||||
}
|
||||
if !ok {
|
||||
fmt.Fprintf(os.Stderr, "cannot close: blocked by %v\n", blockers)
|
||||
return
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user