add subcommand "ximport", that is like "import" but directly access files in the datadir

so mox doesn't have to be running when you run it.
will be useful for testing in the near future.

this also moves cpuprof and memprof cli flags to top-level flag parsing, so all
commands can use them.
This commit is contained in:
Mechiel Lukkien
2023-07-01 16:43:20 +02:00
parent faa08583c0
commit 5817e87a32
4 changed files with 129 additions and 47 deletions

View File

@ -152,6 +152,8 @@ var commands = []struct {
{"updates serve", cmdUpdatesServe},
{"updates verify", cmdUpdatesVerify},
{"gentestdata", cmdGentestdata},
{"ximport maildir", cmdXImportMaildir},
{"ximport mbox", cmdXImportMbox},
}
var cmds []cmd
@ -391,12 +393,19 @@ func main() {
flag.StringVar(&loglevel, "loglevel", "", "if non-empty, this log level is set early in startup")
flag.BoolVar(&pedantic, "pedantic", false, "protocol violations result in errors instead of accepting/working around them")
var cpuprofile, memprofile string
flag.StringVar(&cpuprofile, "cpuprof", "", "store cpu profile to file")
flag.StringVar(&memprofile, "memprof", "", "store mem profile to file")
flag.Usage = func() { usage(cmds, false) }
flag.Parse()
args := flag.Args()
if len(args) == 0 {
usage(cmds, false)
}
defer profile(cpuprofile, memprofile)()
if pedantic {
moxvar.Pedantic = true
}