Skip to content

Commit

Permalink
if file argument is "-" then read from stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
coryb committed Aug 21, 2016
1 parent 20ca3a3 commit b582d9a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions slipscheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,17 @@ type SchemaProcessor struct {
// and write them to the OutputDir
func (s *SchemaProcessor) Process(files []string) error {
for _, file := range files {
fh, err := os.OpenFile(file, os.O_RDONLY, 0644)
defer fh.Close()
var fh *os.File
if file == "-" {
fh = os.Stdin
} else {
var err error
fh, err = os.OpenFile(file, os.O_RDONLY, 0644)
defer fh.Close()
if err != nil {
return err
}
}
b, err := ioutil.ReadAll(fh)
if err != nil {
return err
Expand Down

0 comments on commit b582d9a

Please sign in to comment.