From 8af1c70a8be17543eb33e9bfbbcdd8371e3201cc Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 17 May 2017 12:03:26 +0200 Subject: [PATCH] Renamed --debug to --trace, used for light-client and basecoin --- cli/setup.go | 6 +++--- cli/setup_test.go | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cli/setup.go b/cli/setup.go index 7a4a2098e..21b29a491 100644 --- a/cli/setup.go +++ b/cli/setup.go @@ -16,7 +16,7 @@ import ( const ( RootFlag = "root" HomeFlag = "home" - DebugFlag = "debug" + TraceFlag = "trace" OutputFlag = "output" EncodingFlag = "encoding" ) @@ -36,7 +36,7 @@ func PrepareBaseCmd(cmd *cobra.Command, envPrefix, defautRoot string) Executor { // also, default must be empty, so we can detect this unset and fall back // to --root / TM_ROOT / TMROOT cmd.PersistentFlags().String(HomeFlag, "", "root directory for config and data") - cmd.PersistentFlags().Bool(DebugFlag, false, "print out full stack trace on errors") + cmd.PersistentFlags().Bool(TraceFlag, false, "print out full stack trace on errors") cmd.PersistentPreRunE = concatCobraCmdFuncs(bindFlagsLoadViper, cmd.PersistentPreRunE) return Executor{cmd} } @@ -92,7 +92,7 @@ func (e Executor) Execute() error { err := e.Command.Execute() if err != nil { // TODO: something cooler with log-levels - if viper.GetBool(DebugFlag) { + if viper.GetBool(TraceFlag) { fmt.Printf("ERROR: %+v\n", err) } else { fmt.Println("ERROR:", err.Error()) diff --git a/cli/setup_test.go b/cli/setup_test.go index 6396b769e..8fb4ce140 100644 --- a/cli/setup_test.go +++ b/cli/setup_test.go @@ -184,7 +184,7 @@ func TestSetupUnmarshal(t *testing.T) { } } -func TestSetupDebug(t *testing.T) { +func TestSetupTrace(t *testing.T) { assert, require := assert.New(t), require.New(t) cases := []struct { @@ -193,22 +193,22 @@ func TestSetupDebug(t *testing.T) { long bool expected string }{ - {nil, nil, false, "Debug flag = false"}, - {[]string{"--debug"}, nil, true, "Debug flag = true"}, + {nil, nil, false, "Trace flag = false"}, + {[]string{"--trace"}, nil, true, "Trace flag = true"}, {[]string{"--no-such-flag"}, nil, false, "unknown flag: --no-such-flag"}, - {nil, map[string]string{"DBG_DEBUG": "true"}, true, "Debug flag = true"}, + {nil, map[string]string{"DBG_TRACE": "true"}, true, "Trace flag = true"}, } for idx, tc := range cases { i := strconv.Itoa(idx) // test command that store value of foobar in local variable - debug := &cobra.Command{ - Use: "debug", + trace := &cobra.Command{ + Use: "trace", RunE: func(cmd *cobra.Command, args []string) error { - return errors.Errorf("Debug flag = %t", viper.GetBool(DebugFlag)) + return errors.Errorf("Trace flag = %t", viper.GetBool(TraceFlag)) }, } - cmd := PrepareBaseCmd(debug, "DBG", "/qwerty/asdfgh") // some missing dir.. + cmd := PrepareBaseCmd(trace, "DBG", "/qwerty/asdfgh") // some missing dir.. viper.Reset() args := append([]string{cmd.Use}, tc.args...) @@ -219,7 +219,7 @@ func TestSetupDebug(t *testing.T) { assert.Equal(desired, msg[0], i) if tc.long && assert.True(len(msg) > 2, i) { // the next line starts the stack trace... - assert.Contains(msg[1], "TestSetupDebug", i) + assert.Contains(msg[1], "TestSetupTrace", i) assert.Contains(msg[2], "setup_test.go", i) } }