2026-03-26 12:48:47 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
2026-03-27 02:11:46 +01:00
|
|
|
"strings"
|
2026-03-26 12:48:47 +00:00
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var jsonFlag bool
|
2026-03-27 02:11:46 +01:00
|
|
|
var rootCmd = &cobra.Command{Use: "ax", Short: "The axolotl issue tracker"}
|
2026-03-26 12:48:47 +00:00
|
|
|
|
|
|
|
|
func Execute() {
|
2026-03-27 02:11:46 +01:00
|
|
|
rootCmd.SetArgs(transformArgs(os.Args[1:]))
|
2026-03-26 12:48:47 +00:00
|
|
|
if err := rootCmd.Execute(); err != nil {
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-27 02:11:46 +01:00
|
|
|
func transformArgs(args []string) []string {
|
|
|
|
|
aliases := map[string]string{
|
|
|
|
|
"--status": "_status",
|
|
|
|
|
"--prio": "_prio",
|
|
|
|
|
"--type": "_type",
|
|
|
|
|
"--namespace": "_namespace",
|
|
|
|
|
}
|
|
|
|
|
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:])
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if prop, ok := aliases[args[i]]; ok && i+1 < len(args) {
|
|
|
|
|
result, i = append(result, "--tag", prop+"::"+args[i+1]), i+1
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
result = append(result, args[i])
|
|
|
|
|
}
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 12:48:47 +00:00
|
|
|
func init() {
|
2026-03-27 02:11:46 +01:00
|
|
|
rootCmd.PersistentFlags().BoolVar(&jsonFlag, "json", false, "")
|
2026-03-26 12:48:47 +00:00
|
|
|
}
|