environment

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ListCommand = &cli.Command{
	Name:  "list",
	Usage: "List available deployment environments",
	Action: func(cCtx *cli.Context) error {
		logger := common.LoggerFromContext(cCtx)

		currentEnvConfig, err := utils.GetEnvironmentConfig(cCtx)
		if err != nil {
			return fmt.Errorf("failed to get active deployment environment: %w", err)
		}

		logger.Info("Available deployment environments:")

		for name, config := range common.EnvironmentConfigs {
			marker := ""
			if name == currentEnvConfig.Name {
				marker = " (active)"
			}

			description := utils.GetEnvironmentDescription(name, config.Name, true)

			logger.Info("  • %s %s%s", name, description, marker)
		}

		return nil
	},
}
View Source
var SetCommand = &cli.Command{
	Name:      "set",
	Usage:     "Set deployment environment",
	ArgsUsage: "<environment>",
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:  "yes",
			Usage: "Skip confirmation prompts (for automation)",
		},
	},
	Action: func(cCtx *cli.Context) error {
		logger := common.LoggerFromContext(cCtx)

		if cCtx.NArg() > 1 {
			return fmt.Errorf("too many arguments - expected at most one environment name")
		}

		newEnv, err := utils.GetEnvironmentInteractive(cCtx, 0)
		if err != nil {
			return fmt.Errorf("failed to get environment: %w", err)
		}

		if _, exists := common.EnvironmentConfigs[newEnv]; !exists {
			return fmt.Errorf("unknown environment: %s\nRun 'eigenx environment list' to see available environments", newEnv)
		}

		if common.IsMainnetEnvironment(newEnv) && !cCtx.Bool("yes") {
			if err := utils.ConfirmMainnetEnvironment(newEnv); err != nil {
				return err
			}
		}

		if err := common.SetDefaultEnvironment(newEnv); err != nil {
			return fmt.Errorf("failed to set deployment environment: %w", err)
		}

		logger.Info("✅ Deployment environment set to %s", newEnv)
		return nil
	},
}
View Source
var ShowCommand = &cli.Command{
	Name:  "show",
	Usage: "Show active deployment environment",
	Action: func(cCtx *cli.Context) error {
		logger := common.LoggerFromContext(cCtx)

		envConfig, err := utils.GetEnvironmentConfig(cCtx)
		if err != nil {
			return fmt.Errorf("failed to get environment config: %w", err)
		}

		defaultEnv, err := common.GetDefaultEnvironment()
		if err != nil {
			logger.Debug("Failed to get default environment from global config: %v", err)
		}

		if defaultEnv != "" {
			logger.Info("Active deployment environment: %s", envConfig.Name)
		} else {
			logger.Info("Active deployment environment: %s (fallback default)", envConfig.Name)
			logger.Info("Run 'eigenx environment set <env>' to set your preferred deployment environment")
		}

		logger.Info("Run 'eigenx environment list' to see available deployment environments")

		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