diff --git a/cmd/sst/errors.go b/cmd/sst/errors.go index 2e4bddfad..a78849448 100644 --- a/cmd/sst/errors.go +++ b/cmd/sst/errors.go @@ -20,7 +20,7 @@ func TransformError(err error) error { project.ErrStackRunFailed: "", provider.ErrLockExists: "", project.ErrVersionInvalid: "The version range defined in the config is invalid", - provider.ErrCloudflareMissingAccount: "This cloudflare token does not have access to any accounts. Please make sure the token has the right permissions. You can also set the CLOUDFLARE_DEFAULT_ACCOUNT_ID environment variable to the account id you want to use.", + provider.ErrCloudflareMissingAccount: "The Cloudflare Account ID was not able to be determined from this token. Make sure it has permissions to fetch account information or you can set the CLOUDFLARE_DEFAULT_ACCOUNT_ID environment variable to the account id you want to use.", } readable := []error{ diff --git a/cmd/sst/main.go b/cmd/sst/main.go index 5a8854841..b18c57af5 100644 --- a/cmd/sst/main.go +++ b/cmd/sst/main.go @@ -700,7 +700,7 @@ var Root = Command{ }, { Name: "value", - Required: true, + Required: false, Description: Description{ Short: "The value of the secret", Long: "The value of the secret.", @@ -714,6 +714,12 @@ var Root = Command{ Short: "Set the StripeSecret to 123456789", }, }, + { + Content: "sst secret set StripeSecret < tmp.txt", + Description: Description{ + Short: "Set the StripeSecret to contents of tmp.txt", + }, + }, { Content: "sst secret set StripeSecret productionsecret --stage=production", Description: Description{ diff --git a/cmd/sst/secret.go b/cmd/sst/secret.go index ea8912e41..15cde32cc 100644 --- a/cmd/sst/secret.go +++ b/cmd/sst/secret.go @@ -3,6 +3,7 @@ package main import ( "bufio" "fmt" + "io" "net/http" "os" "regexp" @@ -41,6 +42,30 @@ func CmdSecretList(cli *Cli) error { func CmdSecretSet(cli *Cli) error { key := cli.Positional(0) value := cli.Positional(1) + if value == "" { + stat, err := os.Stdin.Stat() + if err != nil { + return err + } + isTerminal := (stat.Mode() & os.ModeCharDevice) != 0 + if isTerminal { + fmt.Print("Enter value: ") + } + reader := bufio.NewReader(os.Stdin) + for { + input, err := reader.ReadString('\n') + if err != nil { + if err == io.EOF { + break + } + return err + } + value += input + if isTerminal { + break + } + } + } if !regexp.MustCompile(`^[A-Z][a-zA-Z0-9]*$`).MatchString(key) { return util.NewReadableError(nil, "Secret names must start with a capital letter and contain only letters and numbers") }