storj-sim: add option to print a single variable (#1720)
This commit is contained in:
parent
ba891538af
commit
f5155aeb01
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user