From 9404f81aabf15233dfadf8bc136d0a0c57555141 Mon Sep 17 00:00:00 2001 From: Brandon Mulcahy Date: Fri, 17 Jul 2015 01:37:29 -0400 Subject: Allow reassignment of exec.Cmd Stdout and Stderr --- README.md | 13 ++++++++++++- browser.go | 10 ++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 69c00ca..72b1976 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,17 @@ The choice of which browser is started is entirely client dependant. +## Variables +``` go +var Stderr io.Writer = os.Stderr +``` +Stderr is the io.Writer to which executed commands write standard error. + +``` go +var Stdout io.Writer = os.Stdout +``` +Stdout is the io.Writer to which executed commands write standard output. + ## func OpenFile ``` go @@ -41,4 +52,4 @@ OpenURL opens a new browser window pointing to url. - - - -Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md) \ No newline at end of file +Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md) diff --git a/browser.go b/browser.go index cfc9da7..d92c4cd 100644 --- a/browser.go +++ b/browser.go @@ -12,6 +12,12 @@ import ( "path/filepath" ) +// Stdout is the io.Writer to which executed commands write standard output. +var Stdout io.Writer = os.Stdout + +// Stderr is the io.Writer to which executed commands write standard error. +var Stderr io.Writer = os.Stderr + // OpenFile opens new browser window for the file path. func OpenFile(path string) error { path, err := filepath.Abs(path) @@ -50,7 +56,7 @@ func OpenURL(url string) error { func runCmd(prog string, args ...string) error { cmd := exec.Command(prog, args...) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr + cmd.Stdout = Stdout + cmd.Stderr = Stderr return cmd.Run() } -- cgit v1.2.3