Support reading from standard input in pembody.
This commit is contained in:
parent
f7bc97405a
commit
4b9da3632a
|
@ -1,7 +1,8 @@
|
|||
pembody
|
||||
|
||||
This is a utility for decoding PEM-encoded files and spewing their
|
||||
contents to standard output. No trailing newline is appended.
|
||||
contents to standard output. No trailing newline is appended. If
|
||||
the filename is "-", pembody reads from standard input.
|
||||
|
||||
Example:
|
||||
$ cat file.pem
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/kisom/goutils/lib"
|
||||
)
|
||||
|
@ -15,7 +16,15 @@ func main() {
|
|||
lib.Errx(lib.ExitFailure, "a single filename is required")
|
||||
}
|
||||
|
||||
in, err := ioutil.ReadFile(flag.Arg(0))
|
||||
var in []byte
|
||||
var err error
|
||||
|
||||
path := flag.Arg(0)
|
||||
if path == "-" {
|
||||
in, err = ioutil.ReadAll(os.Stdin)
|
||||
} else {
|
||||
in, err = ioutil.ReadFile(flag.Arg(0))
|
||||
}
|
||||
if err != nil {
|
||||
lib.Err(lib.ExitFailure, err, "couldn't read file")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue