67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
package cmd
|
|
|
|
import (
|
|
"os"
|
|
|
|
"git.franklin.lab/steve.cliff/pcli/output"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var boardCmd = &cobra.Command{
|
|
Use: "board",
|
|
Short: "Manage boards",
|
|
Long: "Commands for managing Planka boards",
|
|
}
|
|
|
|
var boardListCmd = &cobra.Command{
|
|
Use: "list",
|
|
Short: "List all accessible boards",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
boards, err := getClient().ListBoards(getContext())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return output.Print(boards, getFormat(), os.Stdout)
|
|
},
|
|
}
|
|
|
|
var boardGetCmd = &cobra.Command{
|
|
Use: "get <id>",
|
|
Short: "Get a board by ID",
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
board, err := getClient().GetBoard(getContext(), args[0])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return output.Print(board, getFormat(), os.Stdout)
|
|
},
|
|
}
|
|
|
|
var boardActionsCmd = &cobra.Command{
|
|
Use: "actions <id>",
|
|
Short: "List actions for a board",
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
limit, _ := cmd.Flags().GetInt("limit")
|
|
|
|
actions, err := getClient().ListBoardActions(getContext(), args[0], limit)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return output.Print(actions, getFormat(), os.Stdout)
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(boardCmd)
|
|
boardCmd.AddCommand(boardListCmd)
|
|
boardCmd.AddCommand(boardGetCmd)
|
|
boardCmd.AddCommand(boardActionsCmd)
|
|
|
|
boardActionsCmd.Flags().Int("limit", 0, "Limit number of actions (0 = no limit)")
|
|
}
|