Skip to content

Commit

Permalink
refactor: change the display of g environment variables, just like 'g…
Browse files Browse the repository at this point in the history
…o env'.
  • Loading branch information
voidint committed Jul 30, 2023
1 parent 688c215 commit d17c1e1
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions cli/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ import (
"fmt"
"os"

"github.com/fatih/color"
"github.com/urfave/cli/v2"
)

func showEnv(ctx *cli.Context) (err error) {
var envVars = []string{experimentalEnv, homeEnv, mirrorEnv}
var envNames = []string{
homeEnv,
mirrorEnv,
experimentalEnv,
}

for _, e := range envVars {
v, set := os.LookupEnv(e)
if !set {
color.New(color.FgYellow).Fprintf(os.Stdout, "%s=(UNSET)\n", e)
} else {
fmt.Printf("%s=%s\n", e, v)
}
func showEnv(ctx *cli.Context) (err error) {
for _, e := range envNames {
fmt.Printf("%s=%q\n", e, os.Getenv(e))
}
return nil
}

0 comments on commit d17c1e1

Please sign in to comment.