diff --git a/cmd/storj-sim/main.go b/cmd/storj-sim/main.go index 4b5bded9b..d46e85acd 100644 --- a/cmd/storj-sim/main.go +++ b/cmd/storj-sim/main.go @@ -66,7 +66,7 @@ func main() { return networkExec(&flags, args, "run") }, }, &cobra.Command{ - Use: "env", + Use: "env [name]", Short: "print environment variables", RunE: func(cmd *cobra.Command, args []string) (err error) { return networkEnv(&flags, args) diff --git a/cmd/storj-sim/network.go b/cmd/storj-sim/network.go index 49cdf24d8..db0f5f8b5 100644 --- a/cmd/storj-sim/network.go +++ b/cmd/storj-sim/network.go @@ -70,6 +70,19 @@ func networkEnv(flags *Flags, args []string) error { } } + if len(args) == 1 { + envprefix := strings.ToUpper(args[0] + "=") + // find the environment value that the environment variable is set to + for _, env := range processes.Env() { + if strings.HasPrefix(strings.ToUpper(env), envprefix) { + fmt.Println(env[len(envprefix):]) + return nil + } + } + + return nil + } + for _, env := range processes.Env() { fmt.Println(env) }