create

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

cmd/project/labels/create/create.go

Index

Constants

This section is empty.

Variables

View Source
var CreateCmd = &cobra.Command{
	Use:     "create --name <label-name>",
	Short:   "Create a new label in the repository.",
	Example: `  contextvibes project labels create --name "docs" --description "Documentation updates" --color "0075ca"`,
	RunE: func(cmd *cobra.Command, args []string) error {
		presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr())
		ctx := cmd.Context()

		if strings.TrimSpace(labelName) == "" {
			return errors.New("label name cannot be empty, please provide the --name flag")
		}

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

			return err
		}

		newLabel := workitem.Label{
			Name:        labelName,
			Description: labelDescription,
			Color:       labelColor,
		}

		presenter.Summary("Creating label '%s'...", newLabel.Name)
		_, err = provider.CreateLabel(ctx, newLabel)
		if err != nil {
			presenter.Error("Failed to create label: %v", err)

			return err
		}

		presenter.Success("Successfully created label '%s'.", newLabel.Name)

		return nil
	},
}

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