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

Config from file #2754

Closed
wants to merge 2 commits into from
Closed

Conversation

realbigsean
Copy link
Member

Issue Addressed

Resolves: #2748

Proposed Changes

clap currently makes it very difficult to overwrite cli arguments. It might be more feasible with clap v3.0.0 which is currently in beta, because that introduces the method App::mut_arg, which we might be able to use to update default argument values at runtime. And App::get_matches_mut(), which allows you to get argument matches without consuming App.

So rather than using native clap functionality, this PR creates a wrapper struct around ArgMatches, with fallback logic to check a given config file for missing args (as @paulhauner suggested) . The glaring weakness of this though, is that we lose out on clap's validation for any arguments we get from file. So far I've found that our error handling is covering a lot of this validation well anyways, but it does fail with less information that clap would. And I haven't yet tested out all of lighthouse's flags and options.

Another potential option is to move towards a declarative style like structopt, which is being rolled into clap_derive in clap v3.0.0 (clap-rs/clap#1661). This style does make it simpler to update args at runtime.

@realbigsean realbigsean added the work-in-progress PR is a work-in-progress label Oct 29, 2021
@realbigsean realbigsean changed the title Config from file2 Config from file Oct 29, 2021
@realbigsean
Copy link
Member Author

Closing in favor of #2808

@realbigsean realbigsean deleted the config-from-file2 branch November 21, 2023 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
work-in-progress PR is a work-in-progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant