From 38bf1f859c8fe722a9fe64cb7c6b6d951f2d2f88 Mon Sep 17 00:00:00 2001 From: Michail Safronov Date: Wed, 24 Jul 2019 02:40:35 +0500 Subject: [PATCH] pkg/config: add max-variable-recurse parameter (#1626) * add max-variable-recurse parameter --- pkg/config/config.go | 6 ++++++ pkg/terminal/command_test.go | 10 ++++++++++ pkg/terminal/terminal.go | 3 +++ 3 files changed, 19 insertions(+) diff --git a/pkg/config/config.go b/pkg/config/config.go index 59b92738ee..500ee918c7 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -42,6 +42,9 @@ type Config struct { // MaxArrayValues is the maximum number of array items that the commands // print, locals, args and vars should read (in verbose mode). MaxArrayValues *int `yaml:"max-array-values,omitempty"` + // MaxVariableRecurse is output evaluation depth of nested struct members, array and + // slice items and dereference pointers + MaxVariableRecurse *int `yaml:"max-variable-recurse,omitempty"` // If ShowLocationExpr is true whatis will print the DWARF location // expression for its argument. @@ -216,6 +219,9 @@ substitute-path: # Maximum loaded string length. # max-string-len: 64 +# Output evaluation. +# max-variable-recurse: 1 + # Uncomment the following line to make the whatis command also print the DWARF location expression of its argument. # show-location-expr: true diff --git a/pkg/terminal/command_test.go b/pkg/terminal/command_test.go index bb6338914b..1237d192ea 100644 --- a/pkg/terminal/command_test.go +++ b/pkg/terminal/command_test.go @@ -739,6 +739,16 @@ func TestConfig(t *testing.T) { if *term.conf.MaxStringLen != 10 { t.Fatalf("expected MaxStringLen 10, got: %d", *term.conf.MaxStringLen) } + err = configureCmd(&term, callContext{}, "max-variable-recurse 4") + if err != nil { + t.Fatalf("error executing configureCmd(max-variable-recurse): %v", err) + } + if term.conf.MaxVariableRecurse == nil { + t.Fatalf("expected MaxVariableRecurse 4, got nil") + } + if *term.conf.MaxVariableRecurse != 4 { + t.Fatalf("expected MaxVariableRecurse 4, got: %d", *term.conf.MaxVariableRecurse) + } err = configureCmd(&term, callContext{}, "substitute-path a b") if err != nil { diff --git a/pkg/terminal/terminal.go b/pkg/terminal/terminal.go index 6475acb6b4..cb59de9c46 100644 --- a/pkg/terminal/terminal.go +++ b/pkg/terminal/terminal.go @@ -414,6 +414,9 @@ func (t *Term) loadConfig() api.LoadConfig { if t.conf != nil && t.conf.MaxArrayValues != nil { r.MaxArrayValues = *t.conf.MaxArrayValues } + if t.conf != nil && t.conf.MaxVariableRecurse != nil { + r.MaxVariableRecurse = *t.conf.MaxVariableRecurse + } return r }