49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
|
|
package cmd
|
||
|
|
|
||
|
|
import (
|
||
|
|
"axolotl/db"
|
||
|
|
"axolotl/output"
|
||
|
|
"fmt"
|
||
|
|
"os"
|
||
|
|
|
||
|
|
"github.com/spf13/cobra"
|
||
|
|
)
|
||
|
|
|
||
|
|
var listType, listStatus, listPrio, listNamespace, listTag, listInbox, listAssignee string
|
||
|
|
|
||
|
|
var listCmd = &cobra.Command{
|
||
|
|
Use: "list",
|
||
|
|
Short: "List nodes",
|
||
|
|
Run: func(cmd *cobra.Command, args []string) {
|
||
|
|
d, err := db.GetDB()
|
||
|
|
if err != nil {
|
||
|
|
fmt.Fprintln(os.Stderr, err)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
nodes, err := d.ListNodes(db.ListFilter{
|
||
|
|
Type: listType,
|
||
|
|
Status: listStatus,
|
||
|
|
Priority: listPrio,
|
||
|
|
Namespace: listNamespace,
|
||
|
|
Tag: listTag,
|
||
|
|
Inbox: listInbox,
|
||
|
|
Assignee: listAssignee,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
output.PrintNodes(cmd.OutOrStdout(), nodes, jsonFlag)
|
||
|
|
},
|
||
|
|
}
|
||
|
|
|
||
|
|
func init() {
|
||
|
|
rootCmd.AddCommand(listCmd)
|
||
|
|
listCmd.Flags().StringVar(&listType, "type", "", "filter by type")
|
||
|
|
listCmd.Flags().StringVar(&listStatus, "status", "", "filter by status")
|
||
|
|
listCmd.Flags().StringVar(&listPrio, "prio", "", "filter by priority")
|
||
|
|
listCmd.Flags().StringVar(&listNamespace, "namespace", "", "filter by namespace")
|
||
|
|
listCmd.Flags().StringVar(&listTag, "tag", "", "filter by tag")
|
||
|
|
listCmd.Flags().StringVar(&listInbox, "inbox", "", "filter by inbox user")
|
||
|
|
listCmd.Flags().StringVar(&listAssignee, "assignee", "", "filter by assignee")
|
||
|
|
}
|