package cmd import ( "axolotl/output" "axolotl/service" "fmt" "os" "github.com/spf13/cobra" ) var lAssignee string var lTags []string var lMention string var listCmd = &cobra.Command{ Use: "list", Short: "List nodes", Run: func(cmd *cobra.Command, args []string) { svc, err := service.GetNodeService(cfg) if err != nil { fmt.Fprintln(os.Stderr, err) return } opts := []service.ListOption{} if len(lTags) > 0 { opts = append(opts, service.WithTags(lTags...)) } if lAssignee != "" { opts = append(opts, service.WithAssignee(lAssignee)) } if lMention != "" { opts = append(opts, service.WithMentions(lMention)) } if nodes, err := svc.List(opts...); err == nil { output.PrintNodes(cmd.OutOrStdout(), svc, nodes, jsonFlag) } else { fmt.Fprintf(os.Stderr, "err: %v\n", err) } }, } func init() { rootCmd.AddCommand(listCmd) addPropertyFlags(listCmd) f := listCmd.Flags() f.StringVar(&lAssignee, "assignee", "", "") f.StringArrayVar(&lTags, "tag", nil, "") f.StringVar(&lMention, "mention", "", "") }