-
-
Notifications
You must be signed in to change notification settings - Fork 190
Description
generally, any option specified on the command line should have precedence over options in the toml file (which have precedence over the default values).
however, the fold_in! macro logic for merging two config structs is slightly flawed. this can cause an option specified at the command line to be deprioritised in favour of a toml config value.
the macro assumes that if the CLI has a default value for an argument, then that should be overridden by the .toml's value (if any). but that's not necessarily correct, because the user may have manually specified a CLI argument that happens to be equal to the default. in these cases, the CLI value should still take precedence over the toml file.
this bug will become more important if lychee wants to do more config file things. in particular, if lychee wants to process multiple config files with precedence between them.
mentioned in #1848
repro:
$ echo 'mode = "task"' > a.toml
$ echo 'https://mock.httpstatus.io/404' | cargo run -- - -v --mode color -c a.toml
[404] https://mock.httpstatus.io/404 | Rejected status code (this depends on your "accept" configuration): Not Found
Issues found in 1 input. Find details below.
[stdin]:
- [ ] [404] https://mock.httpstatus.io/404 | Rejected status code (this depends on your "accept" configuration): Not Foundnote that the mode = task from the config is used even though we specified mode = color on the command line. this is because color coincides with the default value. if you specify a different --mode argument (e.g. emoji), then the CLI value will be correctly used.