Update README with new location
This commit is contained in:
parent
21b6b5267b
commit
63bece879d
3 changed files with 26 additions and 10 deletions
|
|
@ -72,9 +72,9 @@ sudo mv ./discordo /usr/local/bin
|
|||
|
||||
### Configuration
|
||||
|
||||
A default configuration file is created on first start-up at `$HOME/.config/discordo.yml` on Unix, `$HOME/Library/Application Support/discordo.yml` on Darwin, and `%AppData%/discordo.yml` on Windows. The configuration file path can be customized using the `config` command-line flag (eg: `--config ~/myconfigs/discordo.yml`).
|
||||
A default configuration file is created on first start-up at `$HOME/.config/discordo/config.yml` on Unix, `$HOME/Library/Application Support/discordo/config.yml` on Darwin, and `%AppData%/discordo/config.yml` on Windows.
|
||||
|
||||
Similarly, a log file is created on first start-up at `$HOME/.cache/discordo.log` on Unix, `$HOME/Library/Caches/discordo.log` on Darwin, and `%LocalAppData%/discordo.yml` on Windows. The log file path can be customized using the `log` command-line flag.
|
||||
Similarly, a log file is created on first start-up at `$HOME/.cache/discordo/log.txt` on Unix, `$HOME/Library/Caches/discordo/log.txt` on Darwin, and `%LocalAppData%/discordo/log.txt` on Windows.
|
||||
|
||||
## Disclaimer
|
||||
|
||||
|
|
|
|||
|
|
@ -87,17 +87,19 @@ func New() *Config {
|
|||
}
|
||||
|
||||
func (cfg *Config) Load() error {
|
||||
path, _ := os.UserConfigDir()
|
||||
path := DirPath()
|
||||
// Create the configuration directory if it does not exist already.
|
||||
path = filepath.Join(path, Name)
|
||||
err := os.MkdirAll(path, os.ModePerm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
path = filepath.Join(path, "config.yml")
|
||||
// Open the configuration file with create and read-write flag.
|
||||
f, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, os.ModePerm)
|
||||
f, err := os.OpenFile(
|
||||
filepath.Join(path, "config.yml"),
|
||||
os.O_CREATE|os.O_RDWR,
|
||||
os.ModePerm,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -115,3 +117,15 @@ func (cfg *Config) Load() error {
|
|||
|
||||
return yaml.NewDecoder(f).Decode(&cfg)
|
||||
}
|
||||
|
||||
// DirPath returns the path of the configuration directory.
|
||||
func DirPath() string {
|
||||
path, _ := os.UserConfigDir()
|
||||
return filepath.Join(path, Name)
|
||||
}
|
||||
|
||||
// LogDirPath returns the path of the log directory.
|
||||
func LogDirPath() string {
|
||||
path, _ := os.UserCacheDir()
|
||||
return filepath.Join(path, Name)
|
||||
}
|
||||
|
|
|
|||
10
main.go
10
main.go
|
|
@ -16,15 +16,17 @@ var tokenFlag string
|
|||
func init() {
|
||||
flag.StringVar(&tokenFlag, "token", "", "The authentication token.")
|
||||
|
||||
path, _ := os.UserCacheDir()
|
||||
path = filepath.Join(path, config.Name)
|
||||
path := config.LogDirPath()
|
||||
err := os.MkdirAll(path, os.ModePerm)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
path = filepath.Join(path, "logs.txt")
|
||||
f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, os.ModePerm)
|
||||
f, err := os.OpenFile(
|
||||
filepath.Join(path, "logs.txt"),
|
||||
os.O_CREATE|os.O_WRONLY,
|
||||
os.ModePerm,
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue