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

Read configuration file from a default predefined location #233

Open
goetzc opened this issue Apr 10, 2023 · 1 comment
Open

Read configuration file from a default predefined location #233

goetzc opened this issue Apr 10, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@goetzc
Copy link

goetzc commented Apr 10, 2023

Description

Many applications have a default user location for their configuration files, such as $XDG_CONFIG_HOME/<application_name>/config. That way whenever yamlfix runs, it's not necessary to pass it each time an argument to the configuration file location. This is useful for editor integration, such as formatting and linting frameworks that usually just call the application without extra configuration arguments.

Possible Solution

The YAMLlint configuration can be a good inspiration:

To use a custom configuration file, use the -c option:

yamllint -c /path/to/myconfig file-to-lint.yaml

If -c is not provided, yamllint will look for a configuration file in the following locations (by order of preference):

  • a file named .yamllint, .yamllint.yaml, or .yamllint.yml in the current working directory
  • a filename referenced by $YAMLLINT_CONFIG_FILE, if set
  • a file named $XDG_CONFIG_HOME/yamllint/config or ~/.config/yamllint/config, if present

Finally if no config file is found, the default configuration is applied.

Additional context

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Thanks.

@lyz-code
Copy link
Owner

Hi @goetzc sorry for taking so long to answer you. Your feature makes a lot of sense.

The implementation shouldn't be that difficult either as it's already implemented in autoimport another fixer I've made whose repository structure is very similar to this one, so with copy paste it would be kind of easy. Take as reference the next files:

Sadly I won't be able to develop this feature but any pull request will be appreciated

@lyz-code lyz-code added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants