beads/cmd/bd/children.go
beads/crew/emma 9b04d6cc5f fix: bd children includes closed children by default (GH#2481)
The children command now sets --status=all so closed children are visible.
Primary use case for bd children is inspecting all work under a parent,
not just active items.

Fixes #2477

Co-Authored-By: MelsovCOZY <MelsovCOZY@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 11:54:07 -07:00

42 lines
1.4 KiB
Go

package main
import (
"github.com/spf13/cobra"
)
// childrenCmd lists child beads of a parent.
// This is a convenience alias for 'bd list --parent <id> --status all'.
// Unlike plain 'bd list', children includes closed issues by default (GH#2477).
var childrenCmd = &cobra.Command{
Use: "children <parent-id>",
GroupID: "issues",
Short: "List child beads of a parent",
Long: `List all beads that are children of the specified parent bead.
This is a convenience alias for 'bd list --parent <id> --status all'.
Unlike plain 'bd list', children includes closed issues by default,
since the primary use case is inspecting all work under a parent.
Examples:
bd children hq-abc123 # List all children of hq-abc123
bd children hq-abc123 --json # List children in JSON format
bd children hq-abc123 --pretty # Show children in tree format`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
parentID := args[0]
// Set the parent flag on listCmd, run it, then reset
_ = listCmd.Flags().Set("parent", parentID)
defer func() { _ = listCmd.Flags().Set("parent", "") }()
// Include all statuses by default so closed children are visible (GH#2477).
_ = listCmd.Flags().Set("status", "all")
defer func() { _ = listCmd.Flags().Set("status", "") }()
listCmd.Run(listCmd, []string{})
},
}
func init() {
rootCmd.AddCommand(childrenCmd)
}