env

package
v0.7.1-beta Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use:   "env [environment-name]",
	Short: "Execute an environment",
	Long:  "Execute an environment by name. The environment will be searched for in the active profile and all repository configurations. Tasks are executed concurrently and environment variables are set globally.",
	Args:  cobra.RangeArgs(0, 1),
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			active := env.Get()
			if active == "" {
				cmd.PrintErrln("No active environment set.")
			} else {
				cmd.Println("Active environment:", active)
			}
			return
		}

		name := args[0]
		if !env.Contains(name) {
			cmd.PrintErrln("Environment not found:", name)
			return
		}

		cmd.Println("Setting up environment:", name)
		err := raid.WithMutationLock(func() error {
			if err := env.Set(name); err != nil {
				cmd.PrintErrln("Failed to switch environment:", err)
				return err
			}
			if err := raid.ForceLoad(); err != nil {
				cmd.PrintErrln("Failed to reload profile:", err)
				return err
			}
			if err := env.Execute(env.Get()); err != nil {
				cmd.PrintErrln("Failed to execute environment:", err)
				return err
			}
			return nil
		})
		if err != nil {
			return
		}
		cmd.Println("Environment executed successfully.")
	},
}
View Source
var ListEnvCmd = &cobra.Command{
	Use:   "list",
	Short: "List environments",
	Run: func(cmd *cobra.Command, args []string) {
		envs := env.ListAll()
		if len(envs) == 0 {
			fmt.Println("No environments found.")
			return
		}
		fmt.Println("Available environments:")
		for _, env := range envs {
			fmt.Printf("\t%s\n", env)
		}
	},
}

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