Place config & data files according to XDG standarts#557
Place config & data files according to XDG standarts#557
Conversation
There was a problem hiding this comment.
Thanks for your contribution! Unfortunately, it's not this easy, otherwise we would have already done this ourselves.
If we wanted to have XDG basedir spec compliance, we would need to implement the entire spec. Specifically, your PR doesn't address these requirements:
- In addition to
XDG_CONFIG_HOME, the list of paths inXDG_CONFIG_DIRS(including its default value) should also be searched to find the configuration file. - The
config.ymlfile is not the only file that gh writes. There is also the~/.config/gh/state.ymldata file, which should get placed underXDG_DATA_HOME, since it's not a configuration file. - In addition to
XDG_DATA_HOME, the list of paths inXDG_DATA_DIRS(including its default value) should also get searched.
It might be a good idea to search for a Go library that implements all this, instead of implementing it yourself from scratch. This one looks like a good one: https://github.com/OpenPeeDeeP/xdg
Also, some additional considerations:
- The XDG basedir spec is designed for Linux. Since GitHub CLI is cross-platform, how should lookup of these paths be implemented cross-platform, specifically on Windows?
- There are already existing users of GitHub CLI with existing configurations in a set place (
~/.config/gh/*). If support for XDG basedir spec ships in a future release, this might change the location where configuration is looked up for those users, and their old configuration will be discarded. Should we put some code in place that migrates configuration files from old to new location, or will we force users to re-authenticate?
The one I've linked to looks better written to me. It doesn't use |
|
I checked it now, it has |
|
@mislav I implemented this using OpenPeeDeeP/xdg |
|
Also I've got an offtopic question: I've seen a note in contributing guide that you aren't accepting feature PRs now, but I've seen some of those PRs. Are features accepted now? |
|
May I recommend using https://github.com/muesli/go-app-paths/ ? It handles this kind of situation across all platforms, for Unix, macOS and Windows based systems alike. Simple showcase: This results in config being set to (variable portions being already correctly expanded): |
|
Let me add that |
Your project looks nice, but I would say it's a must to support the |
|
@mislav What do you think about current implementation on this branch? |
Sure, let me add that this weekend, I probably have a personal use-case for it now, as well. |
|
@sh7dm I will conduct thorough review next week! Thank you for your patience 🙏 |
|
@sh7dm Just a heads up: I've updated |
|
Apologies for letting this go to seed. This fell into the category of "we want it but failed to make time to stop and incorporate" given the changes we've been making to Given that this PR is now out of date and it sounds like |
Fixes #554