Another Config File PR
Issue Addressed
#2748
Proposed Changes
- Allows reading from a YAML or TOML config file.
- CLI arguments take precedence over file arguments if both are provided
- This also includes a fix to a documentation issue I stumbled on where
advanced-pre-releaseswas linked whenadvanced-release-candidates.mdshould be
Additional Info
The solution here is a combination of what @pawanjay176 suggested here and what the argfile crate provides.
Pawan's solution required using clap to parse and validate the config file flag, and then using clap_derive's update_from to update/validate the original command with the file config. But this requires the extensive migration here, which may take a while to get merged.
argfile circumvents the need for clap_derive's update_from by parsing the config file directly from the cli args and expanding it prior to doing any clap parsing. But it provides no ability to override file config with cli args and requires using a syntax along the lines of lighthouse bn @argfile which is unlike what is provided by other consensus clients.
This solution mimics argfile's preprocessing but is more suited to lighthouse's specific needs. It also does not depend on or conflict with #3007.
Ooh, this is interesting! Very simple to implement. It is a shame you can't override with the CI, but it does make things simpler to reason about!
But it provides no ability to override file config with cli args and requires using a syntax along the lines of
lighthouse bn @argfilewhich is unlike what is provided by other consensus clients.
Looking at the PR, it seems we'd use lighthouse bn --config-file rather than the @argfile?
But it provides no ability to override file config with cli args and requires using a syntax along the lines of lighthouse bn @argfile which is unlike what is provided by other consensus clients.
^ These are limitations of the argfile crate which is why I didn't use that crate in this PR. In this PR you can override file config with CLI and use lighthouse bn --config-file
I'm going to drop the ready-for-review tags due to conflicts. Sorry about letting this one go stale, we can chat about it sometime :)