From 4bc25100b6d24bc9dd37f7b43af5a5bd5fd37f04 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Fri, 6 Jan 2023 14:40:56 -0500 Subject: [PATCH] environment details (#124) --- cmd/zrok/status.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cmd/zrok/status.go b/cmd/zrok/status.go index 3ab178a0..56abfc18 100644 --- a/cmd/zrok/status.go +++ b/cmd/zrok/status.go @@ -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")