cli: Fix support for reading input from stdin - prefer file input
Apparently that way of detecting data on stdin is not really fool proof. Instead of improving that let's just swap the order and look for a file first. yolo.
This commit is contained in:
parent
c82b26b540
commit
f2286d48ff
1 changed files with 2 additions and 2 deletions
4
main.go
4
main.go
|
@ -82,8 +82,6 @@ func render(args []string) {
|
|||
r, path, format := io.Reader(nil), "", ""
|
||||
if fi, err := os.Stdin.Stat(); err != nil {
|
||||
log.Fatal(err)
|
||||
} else if fi.Mode()&os.ModeCharDevice == 0 {
|
||||
r, path, format = os.Stdin, "./STDIN", args[0]
|
||||
} else if len(args) == 2 {
|
||||
f, err := os.Open(args[0])
|
||||
if err != nil {
|
||||
|
@ -91,6 +89,8 @@ func render(args []string) {
|
|||
}
|
||||
defer f.Close()
|
||||
r, path, format = f, args[0], args[1]
|
||||
} else if fi.Mode()&os.ModeCharDevice == 0 {
|
||||
r, path, format = os.Stdin, "./STDIN", args[0]
|
||||
} else {
|
||||
log.Fatal(usage)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue