-
Notifications
You must be signed in to change notification settings - Fork 1
/
opt.go
43 lines (35 loc) · 1.12 KB
/
opt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package importmail
import (
"fmt"
"os"
"path/filepath"
"github.com/alecthomas/kong"
)
type about bool
func (a about) BeforeApply() (err error) {
fmt.Println("Visit https://github.com/gonejack/import-mail")
os.Exit(0)
return
}
type Options struct {
Host string `required:"" help:"Set IMAP host."`
Port int `default:"993" help:"Set IMAP port."`
Username string `required:"" help:"Set IMAP username."`
Password string `required:"" help:"Set IMAP password."`
RemoteDir string `name:"remote-dir" default:"INBOX" help:"Set IMAP directory."`
SizeLimit string `name:"size-limit" default:"20M" help:"Set size limit, mail exceed this limit will be skipped."`
About about `help:"Show about."`
SaveImportedTo string `hidden:"" default:"imported"`
Eml []string `name:".eml" arg:"" optional:"" help:"list of .eml files"`
}
func MustParseOptions() (opt Options) {
kong.Parse(&opt,
kong.Name("import-mail"),
kong.Description("This command line imports .eml files into IMAP account."),
kong.UsageOnError(),
)
if len(opt.Eml) == 0 || opt.Eml[0] == "*.eml" {
opt.Eml, _ = filepath.Glob("*.eml")
}
return
}