37 lines
648 B
Go
37 lines
648 B
Go
package ui
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
type Command struct {
|
|
ConfigFile string
|
|
Mailbox string
|
|
List bool
|
|
}
|
|
|
|
func New() (cmd Command) {
|
|
flag.Usage = func() {
|
|
fmt.Printf("Usage of %s:\n", os.Args[0])
|
|
flag.PrintDefaults()
|
|
}
|
|
home, err := os.UserHomeDir()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
cfgFile := flag.String("cfgFile", home+"/.config/gomail/config.json", "path to config file")
|
|
mailbox := flag.String("mailbox", "inbox", "mailbox to scan messages")
|
|
list := flag.Bool("list", false, "list all mailboxes")
|
|
|
|
flag.Parse()
|
|
|
|
return Command{
|
|
ConfigFile: *cfgFile,
|
|
Mailbox: *mailbox,
|
|
List: *list,
|
|
}
|
|
}
|