From 508a23430b94565dc28414c9587d31626b3ce596 Mon Sep 17 00:00:00 2001 From: Jesse Szwedko Date: Tue, 18 Oct 2016 20:56:31 -0700 Subject: [PATCH] Default app.Writer to os.Stdout As NewApp() does. Fixes #545 --- app.go | 4 ++++ app_test.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/app.go b/app.go index b9adf46..c7e2594 100644 --- a/app.go +++ b/app.go @@ -165,6 +165,10 @@ func (a *App) Setup() { if a.Metadata == nil { a.Metadata = make(map[string]interface{}) } + + if a.Writer == nil { + a.Writer = os.Stdout + } } // Run is the entry point to the cli app. Parses the arguments slice and routes diff --git a/app_test.go b/app_test.go index 23c8aa6..59fea69 100644 --- a/app_test.go +++ b/app_test.go @@ -202,6 +202,12 @@ func TestApp_Command(t *testing.T) { } } +func TestApp_Setup_defaultsWriter(t *testing.T) { + app := &App{} + app.Setup() + expect(t, app.Writer, os.Stdout) +} + func TestApp_CommandWithArgBeforeFlags(t *testing.T) { var parsedOption, firstArg string