Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search config in home and config directories #4

Merged
merged 4 commits into from Jul 18, 2023

Conversation

pophilpo
Copy link
Contributor

@pophilpo pophilpo commented Jul 18, 2023

This MR will add two more directories in which the config will be searched if not found in the current working dir and it's parents.
It will look for config in $HOME if the env var is present and also $XDG_HOME_CONFIG or $HOME/.config

@pophilpo
Copy link
Contributor Author

Now that I think about it, if we are searching in the parents of the current working dir it will reach $HOME anyway 🤔

Copy link
Owner

@sunsided sunsided left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's very useful! I only have one change request related to how the user directories are handled.

Edit: Just see now that you commented on the same note. 😅 Don't assume the .config dir is necessarily under $HOME, so keep both of them, but I'd suggest to not loop through their parents - so the scan should be:

  • Current directors, or
  • parents of current directory, or
  • home directory, or
  • config directory.

I'd go for home first since that seems to take precedence over the more "hidden" config directory on *nix.

src/main.rs Outdated Show resolved Hide resolved
@sunsided sunsided self-assigned this Jul 18, 2023
@sunsided sunsided added the enhancement New feature or request label Jul 18, 2023
@sunsided sunsided merged commit fc7d6c6 into sunsided:main Jul 18, 2023
1 check passed
@sunsided
Copy link
Owner

sunsided commented Jul 18, 2023

Merged and released in 0.3.0.

sunsided added a commit that referenced this pull request Jul 18, 2023
Co-authored-by: Philipp Popov <philolippo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants