Skip to content

Commit

Permalink
fixes bad stdin bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Cooper committed Feb 23, 2017
1 parent eb822e4 commit 1a88d01
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (

"flag"

"io"

"github.com/alistanis/cf_parameter_generator/lib"
)

Expand Down Expand Up @@ -39,7 +41,15 @@ func config() *cfpgen.Config {
}

func main() {
err := cfpgen.Generate(config(), os.Stdin)
var reader io.Reader
stat, err := os.Stdin.Stat()
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
if (stat.Mode() & os.ModeCharDevice) == 0 {
reader = os.Stdin
}
err = cfpgen.Generate(config(), reader)
if err != nil {
fmt.Fprintln(os.Stderr, err)
flag.Usage()
Expand Down

0 comments on commit 1a88d01

Please sign in to comment.