tree

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

cmd/project/issues/tree/tree.go

Index

Constants

This section is empty.

Variables

View Source
var TreeCmd = &cobra.Command{
	Use:     "tree [issue-number]",
	Short:   "Display a hierarchical tree of epics, stories, and tasks.",
	Example: `  contextvibes project issues tree 52 --full`,
	Args:    cobra.MaximumNArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr())
		ctx := cmd.Context()

		provider, err := newProvider(ctx, globals.AppLogger, globals.LoadedAppConfig)
		if err != nil {
			presenter.Error("Failed to initialize work item provider: %v", err)
			return err
		}

		resolver := resolver.New(provider)

		printFunc := printSummaryTree
		if fullView {
			printFunc = printFullTree
		}

		if len(args) > 0 {
			issueNumber, err := strconv.Atoi(args[0])
			if err != nil {
				return fmt.Errorf("invalid issue number provided: %s", args[0])
			}
			presenter.Summary("Building work item tree for Epic #%d...", issueNumber)
			root, err := resolver.BuildTree(ctx, issueNumber, fullView)
			if err != nil {
				presenter.Error("Failed to build work item tree: %v", err)
				return err
			}
			printFunc(presenter, root, 0)
		} else {
			presenter.Summary("Fetching all Epics to build trees...")
			listOpts := workitem.ListOptions{
				State:  workitem.StateOpen,
				Labels: []string{"epic"},
				Limit:  100,
			}
			epics, err := provider.ListItems(ctx, listOpts)
			if err != nil {
				presenter.Error("Failed to list epics: %v", err)
				return err
			}
			if len(epics) == 0 {
				presenter.Info("No open issues with the 'epic' label found.")
				return nil
			}

			for i, epic := range epics {
				root, err := resolver.BuildTree(ctx, epic.Number, fullView)
				if err != nil {
					presenter.Warning("Failed to build tree for Epic #%d: %v", epic.Number, err)
					continue
				}
				if i > 0 {
					presenter.Newline()
				}
				printFunc(presenter, root, 0)
			}
		}

		return nil
	},
}

TreeCmd represents the project issues tree command

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL