Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cmd/gmailctl/cmd/root_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func init() {
// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
rootCmd.PersistentFlags().StringVar(&cfgDir, "config", "", "config directory (default is $HOME/.gmailctl)")
rootCmd.PersistentFlags().StringVar(&cfgDir, "config", "", "config directory (default search paths: $HOME/.gmailctl, $HOME/.config/gmailctl)")
}

// initConfig reads in config file and ENV variables if set.
Expand All @@ -65,6 +65,10 @@ func initConfig() {
fmt.Println(err)
os.Exit(1)
}
cfgDir = path.Join(usr.HomeDir, ".gmailctl")
if _, err := os.Stat(path.Join(usr.HomeDir, ".gmailctl")); err != nil && os.IsNotExist(err) {
cfgDir = path.Join(usr.HomeDir, ".config", "gmailctl")
} else {
cfgDir = path.Join(usr.HomeDir, ".gmailctl")
}
}
}