From eed76df6b5994fae1a5666a02b1101c040f802a0 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 10 Nov 2021 14:36:47 +0100 Subject: [PATCH] Allow import-messages to read from stdin --- cmd/hydroxide/main.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cmd/hydroxide/main.go b/cmd/hydroxide/main.go index f423cc6..a3cc8b8 100644 --- a/cmd/hydroxide/main.go +++ b/cmd/hydroxide/main.go @@ -175,7 +175,7 @@ Commands: carddav Run hydroxide as a CardDAV server export-secret-keys Export secret keys imap Run hydroxide as an IMAP server - import-messages Import messages + import-messages [file] Import messages export-messages [options...] Export messages sendmail -- sendmail(1) interface serve Run all servers @@ -398,15 +398,18 @@ func main() { importMessagesCmd.Parse(flag.Args()[1:]) username := importMessagesCmd.Arg(0) archivePath := importMessagesCmd.Arg(1) - if username == "" || archivePath == "" { - log.Fatal("usage: hydroxide import-messages ") + if username == "" { + log.Fatal("usage: hydroxide import-messages [file]") } - f, err := os.Open(archivePath) - if err != nil { - log.Fatal(err) + f := os.Stdin + if archivePath != "" { + f, err = os.Open(archivePath) + if err != nil { + log.Fatal(err) + } + defer f.Close() } - defer f.Close() bridgePassword, err := askBridgePass() if err != nil {