yamlfix
yamlfix copied to clipboard
Read configuration file from a default predefined location
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 presentFinally if no config file is found, the default configuration is applied.
Additional context
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Thanks.
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:
- https://github.com/lyz-code/autoimport/blob/main/src/autoimport/entrypoints/cli.py
Sadly I won't be able to develop this feature but any pull request will be appreciated