Added list management commands, board filtering by project name, and enhanced skill documentation with bootstrap workflow and error handling patterns. Also added plumbing in to "pcli" binary for status syncing with Planka
This commit is contained in:
@@ -3,6 +3,7 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"git.franklin.lab/steve.cliff/pcli/client"
|
||||
"git.franklin.lab/steve.cliff/pcli/output"
|
||||
@@ -15,15 +16,47 @@ var boardCmd = &cobra.Command{
|
||||
Long: "Commands for managing Planka boards",
|
||||
}
|
||||
|
||||
func resolveProjectNameToID(projectName string) (string, error) {
|
||||
projects, err := getClient().ListProjects(getContext())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for _, project := range projects {
|
||||
if strings.EqualFold(project.Name, projectName) {
|
||||
return project.ID, nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("project not found: %s", projectName)
|
||||
}
|
||||
|
||||
var boardListCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List all accessible boards",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
projectName, _ := cmd.Flags().GetString("project")
|
||||
|
||||
boards, err := getClient().ListBoards(getContext())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if projectName != "" {
|
||||
projectID, err := resolveProjectNameToID(projectName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var filteredBoards []interface{}
|
||||
for _, board := range boards {
|
||||
if board.ProjectID == projectID {
|
||||
filteredBoards = append(filteredBoards, board)
|
||||
}
|
||||
}
|
||||
return output.Print(filteredBoards, getFormat(), os.Stdout)
|
||||
}
|
||||
|
||||
return output.Print(boards, getFormat(), os.Stdout)
|
||||
},
|
||||
}
|
||||
@@ -111,6 +144,8 @@ func init() {
|
||||
boardCmd.AddCommand(boardCreateCmd)
|
||||
boardCmd.AddCommand(boardDeleteCmd)
|
||||
|
||||
boardListCmd.Flags().String("project", "", "Filter boards by project name")
|
||||
|
||||
boardActionsCmd.Flags().Int("limit", 0, "Limit number of actions (0 = no limit)")
|
||||
|
||||
// Flags for board create
|
||||
|
||||
Reference in New Issue
Block a user