package secret import ( "fmt" "github.com/spf13/cobra" "github.com/wild-cloud/wild-cli/internal/config" "github.com/wild-cloud/wild-cli/internal/environment" "github.com/wild-cloud/wild-cli/internal/output" ) func newSetCommand() *cobra.Command { cmd := &cobra.Command{ Use: "set ", Short: "Set a secret value", Long: `Set a secret value in secrets.yaml using a dot-notation path. The value will be stored as-is in the secrets file. Be careful with sensitive data. Examples: wild secret set database.password mySecretPassword123 wild secret set apps.myapp.api_key abc123def456 wild secret set certificates.tls.key "-----BEGIN PRIVATE KEY-----..."`, Args: cobra.ExactArgs(2), RunE: runSet, } return cmd } func runSet(cmd *cobra.Command, args []string) error { path := args[0] value := args[1] // Initialize environment env := environment.New() if err := env.RequiresProject(); err != nil { return err } // Create config manager mgr := config.NewManager(env.ConfigPath(), env.SecretsPath()) // Set the secret value if err := mgr.SetSecret(path, value); err != nil { return fmt.Errorf("setting secret value: %w", err) } // Don't show the actual value in output for security output.Success(fmt.Sprintf("Set secret %s", path)) return nil }