Closed rpdelaney closed 3 years ago
I don't have any strong objections to this. Taking a peek at what I have on my macOS machine, there doesn't seem to be a lot of consistency in where config files for CLIs live:
Interestingly, click's get_app_dir
utility seems to prefer ~/
to ~/.config
for macOS: https://github.com/pallets/click/blob/9d8ad23f8d9f80464c6566db449611c9e9d7571a/src/click/utils.py#L375-L390
All that said, since this can be implemented without adding too much maintenance overhead, I'd review and merge a PR.
appdirs doesn't look it'll do the right thing on macOS:
We almost certainly don't want to use ~/Library/Preferences/
, right? IIUC that's more for GUI Mac apps.
Weirdly enough, click's get_app_dir
also won't use XDG_CONFIG_HOME or ~/.config/ on macOS: https://github.com/pallets/click/blob/a4763ef93734ccfea497ea10bf0870d588132432/src/click/utils.py#L375-L378
🤔 Is it just me, or do both those implementations look incorrect for CLIs?
I can't give an informed opinion about what is appropriate in the macOS ecosystem, unfortunately. What history I can find on how appdirs
came to be in its current state is a bit labyrithine as well -- there doesn't seem to be a comprehensive statement on their current understanding of the state of the world from their POV that explains the rationale behind these decisions. At least, not that I can find. But using $HOME/.config
on macOS seems somehow wrong in an intangible way that I can't clearly articulate. (Maybe that means it's not really a problem though.)
Regardless, I have all my own stuff in $HOME/.config
on macOS too just because so many tools I use presume you're on a *NIX type system and put things there without thinking twice about it. So for my selfish purposes, doing that here is fine with me, if that's the way you want to go.
Well, your original proposal is better than what appdirs and click are doing. Preferring $HOME/.config
across platforms seems a lot better than using
~/Library/Preferences/
on macOS and C:\Documents and Settings\<username>\Application Data\<AppAuthor>\<AppName>
on Windows.
Here's what flake8 does: https://github.com/PyCQA/flake8/blob/a42d8cbed40dda51c22ee80ee558b2ef60eb3806/src/flake8/options/config.py#L58-L69
IIUC, your proposal is to do the same except with a fallback to ~/.konchrc.default
to maintain backwards compatibility.
IIUC, your proposal is to do the same except with a fallback to ~/.konchrc.default to maintain backwards compatibility.
That's the spirit anyway. Roughly:
if $XDG_CONFIG_HOME/konchrc.default exists:
use that
else if ~/.config/konchrc.default exists
use that
else if ~/.konchrc.default exists
use that
If none are found and we want to create one, create it in env.get(XDG_CONFIG_HOME, ~/.config)
Edit: re- the above, I don't remember if konch creates the config for the user at any point. If not, the last bit wouldn't be needed
Yep, that logic looks right.
I don't remember if konch creates the config for the user at any point. If not, the last bit wouldn't be needed
IIRC that functionality to create the config doesn't exist.
From the XDG base directory spec:
Rather than force anyone to migrate, a fallback strategy would be an option:
$XDG_CONFIG_HOME/konchrc.default
$HOME/.config/konchrc.default
$HOME/.konchrc.default
If you would be open to a PR on this, I could maybe put something together.