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

Feature - Config Loading Improvements #36

Merged

Conversation

Rican7
Copy link
Owner

@Rican7 Rican7 commented Mar 6, 2024

This PR adds support for loading config files in multiple locations, based on the OS and environment that the app is running on, and adheres to the XDG Base Directory Specification for the locations that it searches for in *nix/Unix-like environments.

It also tweaks configuration fallback-order/precedence to use the more common ordering of:

  1. Command line flags
  2. Environment variables
  3. A configuration file
  4. Default values

Finally, in order to help with the environment-dependent config loading pattern (that makes static documentation more challenging), this PR adds a --debug-config flag to have the application self-document and describe it's config file loading status and print the paths that are searched for config files.

 - The flags will now receive and be able to display the default values.
 - The config file is now searched across multiple paths:
   - One that respects the XDG Base Directory Specification.
   - The old default of `~/.define.conf.json`, for fallback.
We now check for a user's XDG config home path, then the old default
path, and then finally the more "system" level XDG config dirs.
Config merging now handles private values.
@Rican7 Rican7 added the Feature label Mar 6, 2024
@Rican7 Rican7 self-assigned this Mar 6, 2024
@Rican7 Rican7 merged commit 234d2b3 into main Mar 6, 2024
2 checks passed
@Rican7 Rican7 deleted the feature/config-improvement-and-xdg-basedir-spec-compliance branch March 6, 2024 04:26
Rican7 added a commit that referenced this pull request Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant