-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #11029 - epage:config, r=weihanglo
refactor(cli): Lazy load config This is trying to clarify `-C` support when it is implemented in #10952 Cargo currently has two initialization states for Config, `Config::default` (process start) and `config.configure` (after parsing args). The most help we provide for a developer touching this code is a giant `CAUTION` comment in one of the relevant functions. Currently, #10952 adds another configuration state in the middle where the `current_dir` has been set. The goal of this PR is to remove that third configuration state by - Lazy loading `Config::default` so it can be called after parsing `-C` - Allowing `-C` support to assert that the config isn't loaded yet to catch bugs with it The hope is this will make the intent of the code clearer and reduce the chance for bugs. In doing this, there are two intermediate refactorings - Make help behave like other subcommands - Before, we had hacks to intercept raw arguments and to intercept clap errors and assume what their intention was to be able to implement our help system. - This flips it around and makes help like any other subcommand, simplifying cargo initialization. - We had to upgrade clap because this exposed a bug where `Command::print_help` wasn't respecting `disable_colored_help(true)` - Delay fix's access to config Personally, I also find both changes make the intent of the code clearer. To review this, I recommend looking at the individual commits. As this is just refactors, this has no impact on testing.
- Loading branch information
Showing
7 changed files
with
93 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters