From 480c853a3ec36c0a1246f1f27a3640548c7d6766 Mon Sep 17 00:00:00 2001 From: Yuce Tekol Date: Wed, 5 Sep 2018 16:23:31 +0300 Subject: [PATCH 1/2] Use passed stdin, stdout and stderr in the cmd package. Fixes #1538 --- cmd/check.go | 5 ++--- cmd/config.go | 3 +-- cmd/export.go | 2 +- cmd/generate_config.go | 5 ++--- cmd/inspect.go | 5 ++--- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/cmd/check.go b/cmd/check.go index d7bd33afd..19e0519a8 100644 --- a/cmd/check.go +++ b/cmd/check.go @@ -18,7 +18,6 @@ import ( "context" "fmt" "io" - "os" "github.com/spf13/cobra" @@ -27,8 +26,8 @@ import ( var checker *ctl.CheckCommand -func newCheckCommand(_ io.Reader, _, _ io.Writer) *cobra.Command { - checker = ctl.NewCheckCommand(os.Stdin, os.Stdout, os.Stderr) +func newCheckCommand(stdin io.Reader, stdout io.Writer, stderr io.Writer) *cobra.Command { + checker = ctl.NewCheckCommand(stdin, stdout, stderr) checkCmd := &cobra.Command{ Use: "check [path2]...", Short: "Do a consistency check on a pilosa data file.", diff --git a/cmd/config.go b/cmd/config.go index a877d12ef..73464ba65 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -17,7 +17,6 @@ package cmd import ( "context" "io" - "os" "github.com/spf13/cobra" @@ -28,7 +27,7 @@ import ( var conf *ctl.ConfigCommand func newConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { - conf = ctl.NewConfigCommand(os.Stdin, os.Stdout, os.Stderr) + conf = ctl.NewConfigCommand(stdin, stdout, stderr) Server := server.NewCommand(stdin, stdout, stderr) confCmd := &cobra.Command{ Use: "config", diff --git a/cmd/export.go b/cmd/export.go index 217e9f09c..4e7c4d232 100644 --- a/cmd/export.go +++ b/cmd/export.go @@ -26,7 +26,7 @@ import ( var Exporter *ctl.ExportCommand -func newExportCommand(_ io.Reader, _, _ io.Writer) *cobra.Command { +func newExportCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { Exporter = ctl.NewExportCommand(os.Stdin, os.Stdout, os.Stderr) exportCmd := &cobra.Command{ Use: "export", diff --git a/cmd/generate_config.go b/cmd/generate_config.go index 6421a1f4f..8c8553aa4 100644 --- a/cmd/generate_config.go +++ b/cmd/generate_config.go @@ -17,7 +17,6 @@ package cmd import ( "context" "io" - "os" "github.com/spf13/cobra" @@ -26,8 +25,8 @@ import ( var generateConf *ctl.GenerateConfigCommand -func newGenerateConfigCommand(_ io.Reader, _, _ io.Writer) *cobra.Command { - generateConf = ctl.NewGenerateConfigCommand(os.Stdin, os.Stdout, os.Stderr) +func newGenerateConfigCommand(stdin io.Reader, stdout io.Writer, stderr io.Writer) *cobra.Command { + generateConf = ctl.NewGenerateConfigCommand(stdin, stdout, stderr) confCmd := &cobra.Command{ Use: "generate-config", Short: "Print the default configuration.", diff --git a/cmd/inspect.go b/cmd/inspect.go index 4f5ff9301..570e7aae3 100644 --- a/cmd/inspect.go +++ b/cmd/inspect.go @@ -18,7 +18,6 @@ import ( "context" "fmt" "io" - "os" "github.com/spf13/cobra" @@ -27,8 +26,8 @@ import ( var inspector *ctl.InspectCommand -func newInspectCommand(_ io.Reader, _, _ io.Writer) *cobra.Command { - inspector = ctl.NewInspectCommand(os.Stdin, os.Stdout, os.Stderr) +func newInspectCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { + inspector = ctl.NewInspectCommand(stdin, stdout, stderr) inspectCmd := &cobra.Command{ Use: "inspect", From fe1208ac656d1ce4d21b6418a741280e31b7023a Mon Sep 17 00:00:00 2001 From: Yuce Tekol Date: Wed, 5 Sep 2018 17:37:44 +0300 Subject: [PATCH 2/2] Fix std{in,out,err} in export cmd --- cmd/export.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/export.go b/cmd/export.go index 4e7c4d232..6cfeb0d9c 100644 --- a/cmd/export.go +++ b/cmd/export.go @@ -17,7 +17,6 @@ package cmd import ( "context" "io" - "os" "github.com/spf13/cobra" @@ -27,7 +26,7 @@ import ( var Exporter *ctl.ExportCommand func newExportCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { - Exporter = ctl.NewExportCommand(os.Stdin, os.Stdout, os.Stderr) + Exporter = ctl.NewExportCommand(stdin, stdout, stderr) exportCmd := &cobra.Command{ Use: "export", Short: "Export data from pilosa.",