add output to stdout

This commit is contained in:
Jay 2018-03-13 16:38:52 +08:00
parent 648a3259c2
commit 8a9be9c126

16
main.go
View File

@ -50,6 +50,7 @@ func main() {
if !tools.CheckExists(flags.SrcFile, false) {
log.Fatal("SrcFile not exists")
}
if flags.DstFile != "-" {
dir := path.Dir(flags.DstFile)
if !tools.CheckExists(dir, true) {
log.Fatal("DstFile parent directory not exists")
@ -57,10 +58,13 @@ func main() {
if !flags.Override && tools.CheckExists(flags.DstFile, false) {
log.Fatal("DstFile has Exists if override add flag -y ")
}
flags.DstFile = tools.ParsePath(flags.DstFile)
}
flags.KeyFile = tools.ParsePath(flags.KeyFile)
flags.SrcFile = tools.ParsePath(flags.SrcFile)
flags.DstFile = tools.ParsePath(flags.DstFile)
// fmt.Println(flags.ToMap())
if flags.Encrypt {
// encrypt()
@ -70,8 +74,11 @@ func main() {
srcIO, err := os.Open(flags.SrcFile)
handleError(err)
dstIO, err := os.Create(flags.DstFile)
dstIO := os.Stdout
if flags.DstFile != "-" {
dstIO, err = os.Create(flags.DstFile)
handleError(err)
}
err = pgpcrypt.Encrypt2(keyIO, srcIO, dstIO)
@ -86,8 +93,11 @@ func main() {
srcIO, err := os.Open(flags.SrcFile)
handleError(err)
dstIO, err := os.Create(flags.DstFile)
dstIO := os.Stdout
if flags.DstFile != "-" {
dstIO, err = os.Create(flags.DstFile)
handleError(err)
}
err = pgpcrypt.Decrypt2(keyIO, srcIO, dstIO, flags.Password)
// err := pgpcrypt.Decrypt(flags.KeyFile, flags.SrcFile, flags.DstFile, flags.Password)