view

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: 14 Imported by: 0

Documentation

Overview

Package view provides the command to view issue details.

Index

Constants

This section is empty.

Variables

View Source
var ViewCmd = &cobra.Command{
	Use:     "view <issue-number>",
	Short:   "Display the details of a specific issue.",
	Example: `  contextvibes project issues view 123 --comments`,
	Args:    cobra.ExactArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr())
		ctx := cmd.Context()

		issueNumber, err := strconv.Atoi(args[0])
		if err != nil {

			return errors.New("invalid issue number provided")
		}

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

			return err
		}

		presenter.Summary("Fetching details for work item #%d...", issueNumber)
		item, err := provider.GetItem(ctx, issueNumber, withComments)
		if err != nil {
			presenter.Error("Failed to fetch work item: %v", err)

			return fmt.Errorf("failed to get item: %w", err)
		}

		internal.DisplayWorkItem(presenter, item)

		if withComments {

			fmt.Fprintf(presenter.Out(), "\n--- Comments (%d) ---\n\n", len(item.Comments))
			for _, comment := range item.Comments {
				presenter.Header(
					fmt.Sprintf(
						"Comment by %s on %s",
						comment.Author,
						comment.CreatedAt.Format("2006-01-02"),
					),
				)

				fmt.Fprintln(presenter.Out(), comment.Body)
				presenter.Separator()
			}
		}

		return nil
	},
}

ViewCmd represents the project issues view 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