Skip to content

Commit

Permalink
Allow import-messages to read from stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed Nov 10, 2021
1 parent 9876df6 commit eed76df
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cmd/hydroxide/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Commands:
carddav Run hydroxide as a CardDAV server
export-secret-keys <username> Export secret keys
imap Run hydroxide as an IMAP server
import-messages <username> <file> Import messages
import-messages <username> [file] Import messages
export-messages [options...] <username> Export messages
sendmail <username> -- <args...> sendmail(1) interface
serve Run all servers
Expand Down Expand Up @@ -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 <username> <file>")
if username == "" {
log.Fatal("usage: hydroxide import-messages <username> [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 {
Expand Down

0 comments on commit eed76df

Please sign in to comment.