setproject

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SetProjectCmd = &cobra.Command{
	Use:   "set-project <id>",
	Short: "Set the project ID",
	Long:  `Set the project ID for the Hyphen CLI to use.`,
	Args:  cobra.ExactArgs(1),
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		return user.ErrorIfNotAuthenticated()
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		printer = cprint.NewCPrinter(flags.VerboseFlag)
		projectID := args[0]
		var err error

		restoredConfig, err := config.RestoreConfig()
		if err != nil {
			return errors.Wrapf(err, "failed to restore config")
		}

		orgID := restoredConfig.OrganizationId
		projectService := projects.NewService(orgID)
		project, err := projectService.GetProject(projectID)
		if err != nil {
			return errors.Wrapf(err, "failed to get project %q. Is that a valid project ID or alternate ID?", projectID)
		}

		if globalFlag {
			err = config.UpsertGlobalProject(project)
		} else {
			err = config.UpsertProject(project)
		}

		if err != nil {
			return fmt.Errorf("failed to update project ID: %w", err)
		}
		printProjectUpdateSuccess(projectID, globalFlag)
		return nil
	},
}

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