Skip to content

Commit

Permalink
Fix ctx command, now it updates config file
Browse files Browse the repository at this point in the history
  • Loading branch information
anton.prokhorov committed Jan 12, 2024
1 parent f7f6c4e commit 48bd413
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ func addContextCommand(root *cobra.Command) {
cmd := &cobra.Command{
Use: "ctx",
Short: "Change current context parameters",
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {

// Save current config
if err := viper.WriteConfig(); err != nil {
return fmt.Errorf("fail to save config: %w", err)
}

// Print values from current context.
fields := reflect.VisibleFields(reflect.TypeOf(cfg.Context))
Expand All @@ -111,6 +116,8 @@ func addContextCommand(root *cobra.Command) {
color.Bold.Print(field.Tag.Get("mapstructure") + ": ")
color.Println(v.FieldByName(field.Name))
}

return nil
},
}

Expand Down

0 comments on commit 48bd413

Please sign in to comment.