minor changnes to default config path
Signed-off-by: Michael <michael.lindman@gmail.com>
This commit is contained in:
parent
d98c3c539e
commit
c5a2892136
@ -10,6 +10,7 @@ import (
|
||||
// Config application configuration
|
||||
type Config struct {
|
||||
Addr string `yaml:"addr"`
|
||||
Path string `yaml:"path"`
|
||||
Account []struct {
|
||||
Username string `yaml:"username"`
|
||||
Password string `yaml:"password"`
|
||||
|
17
main.go
17
main.go
@ -3,7 +3,9 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"git.0cd.xyz/michael/gomail/mail"
|
||||
"git.0cd.xyz/michael/gtools/logger"
|
||||
@ -28,9 +30,11 @@ func main() {
|
||||
if err != nil {
|
||||
chErr <- err
|
||||
}
|
||||
path := "./msgs/" + username
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
os.Mkdir(path, 0775)
|
||||
path := cfg.Path + username + "/" + time.Now().Format("2006-01-02-15:04:05")
|
||||
for _, p := range []string{cfg.Path + username, path} {
|
||||
if _, err := os.Stat(p); os.IsNotExist(err) {
|
||||
os.Mkdir(p, 0775)
|
||||
}
|
||||
}
|
||||
if err := mail.WriteMessages(path, messages); err != nil {
|
||||
chErr <- err
|
||||
@ -52,8 +56,11 @@ func ui() (cfgFile, mailbox *string, msgs *int) {
|
||||
fmt.Printf("Usage of %s:\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
cfgFile = flag.String("cfgFile", "./config.yaml", "path to config file")
|
||||
home, ok := os.LookupEnv("HOME")
|
||||
if !ok {
|
||||
log.Fatal("Unable to find home directory")
|
||||
}
|
||||
cfgFile = flag.String("cfgFile", home+"/.config/gomail/config.yaml", "path to config file")
|
||||
mailbox = flag.String("mailbox", "inbox", "mailbox to scan messages")
|
||||
msgs = flag.Int("msgs", 100, "Number of messages to pull")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user