Skip to content

Move config file default path to os.UserConfigDir() #161

@wijayaerick

Description

@wijayaerick

Related with #116

os.UserConfigDir() docs:

On Unix systems, it returns $XDG_CONFIG_HOME as specified by https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if non-empty, else $HOME/.config. On Darwin, it returns $HOME/Library/Application Support. On Windows, it returns %AppData%. On Plan 9, it returns $home/lib.

Currently .wegorc defaults to $HOME/.wegorc in all systems. I'm proposing this logic for searching/creating the config file:

  1. $WEGORC takes the highest precedence.
  2. If $WEGORC is not set, try to open the config file from os.UserConfigDir()/wego/wegorc (can adjust the name, but the point is it is stored inside os.UserConfigDir)
  3. If the config file is not found, fallback try to open the config file from $HOME/.wegorc for backward compatibility
  4. If still now found, generate the config file
    • in $WEGORC if it is set
    • else, generate the file in os.UserConfigDir()/wego/wegorc

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions