environment details (#124)

This commit is contained in:
Michael Quigley 2023-01-06 14:40:56 -05:00
parent 7f5321f416
commit 4bc25100b6
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62

View File

@ -2,6 +2,7 @@ package main
import (
"fmt"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/openziti-test-kitchen/zrok/zrokdir"
"github.com/spf13/cobra"
"os"
@ -30,10 +31,22 @@ func newStatusCommand() *statusCommand {
func (cmd *statusCommand) run(_ *cobra.Command, _ []string) {
_, _ = fmt.Fprintf(os.Stderr, "\n")
_, err := zrokdir.LoadEnvironment()
env, err := zrokdir.LoadEnvironment()
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "%v: Unable to load your local environment! (%v)\n\n", warningLabel, err)
_, _ = fmt.Fprintf(os.Stderr, "To create a local environment use the %v command.\n", codeStyle.Render("zrok enable"))
} else {
_, _ = fmt.Fprintf(os.Stdout, codeStyle.Render("Environment"+":\n"))
_, _ = fmt.Fprintf(os.Stdout, "\n")
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.SetStyle(table.StyleColoredDark)
t.AppendHeader(table.Row{"Property", "Value"})
t.AppendRow(table.Row{"API Endpoint", env.ApiEndpoint})
t.AppendRow(table.Row{"Secret Token", env.Token})
t.AppendRow(table.Row{"Ziti Identity", env.ZId})
t.Render()
}
_, _ = fmt.Fprintf(os.Stderr, "\n")