create

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: 13 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 create provides the command to create new issues.

Index

Constants

This section is empty.

Variables

View Source
var CreateCmd = &cobra.Command{
	Use:     "create",
	Aliases: []string{"new", "add"},
	RunE: func(cmd *cobra.Command, _ []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
		}

		if issueTitle == "" {
			form := huh.NewForm(
				huh.NewGroup(

					huh.NewSelect[string]().Title("What kind of issue is this?").
						Options(huh.NewOption("Task", "Task"), huh.NewOption("Story", "Story"), huh.NewOption("Bug", "Bug"), huh.NewOption("Chore", "Chore")).
						Value(&issueType),
					huh.NewInput().Title("Title?").Value(&issueTitle),
					huh.NewText().Title("Body?").Value(&issueBody),
				),
			)
			err := form.Run()
			if err != nil {
				return fmt.Errorf("input form failed: %w", err)
			}
		}

		if issueTitle == "" {

			return errors.New("title cannot be empty")
		}

		newItem := workitem.WorkItem{
			Title: issueTitle,
			Body:  issueBody,
			Type:  workitem.Type(issueType),
		}

		presenter.Summary("Creating work item...")
		createdItem, err := provider.CreateItem(ctx, newItem)
		if err != nil {
			presenter.Error("Failed to create work item: %v", err)

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

		presenter.Success("Successfully created work item: %s", createdItem.URL)

		return nil
	},
}

CreateCmd represents the project issues create 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