Skip to content

Commit

Permalink
Print client context (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
nt0xa authored Feb 20, 2023
1 parent bc9f9f3 commit c9b3d00
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"os"
"reflect"

"github.com/adrg/xdg"
"github.com/gookit/color"
Expand Down Expand Up @@ -134,6 +135,14 @@ func addContextCmd(cfg *Config, root *cobra.Command) {
fatalf("Fail to update config: %v", err)
}

// Print values from current context.
fields := reflect.VisibleFields(reflect.TypeOf(cfg.Context))
v := reflect.ValueOf(cfg.Context)
for _, field := range fields {
color.Bold.Print(field.Tag.Get("mapstructure") + ": ")
color.Println(v.FieldByName(field.Name))
}

return nil
},
}
Expand Down

0 comments on commit c9b3d00

Please sign in to comment.