tree

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: MIT Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tree provides the command to display issue hierarchy.

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 fmt.Errorf("failed to build tree: %w", 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 fmt.Errorf("failed to list epics: %w", 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