Skip to content

Commit cbda532

Browse files
committed
Access term config through a deserialized type
Going through and removing users of raw `get_*` functions!
1 parent 2357bb0 commit cbda532

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/cargo/util/config/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,13 +593,18 @@ impl Config {
593593
let extra_verbose = verbose >= 2;
594594
let verbose = if verbose == 0 { None } else { Some(true) };
595595

596+
#[derive(Deserialize, Default)]
597+
struct TermConfig {
598+
verbose: Option<bool>,
599+
color: Option<String>,
600+
}
601+
596602
// Ignore errors in the configuration files.
597-
let cfg_verbose = self.get_bool("term.verbose").unwrap_or(None).map(|v| v.val);
598-
let cfg_color = self.get_string("term.color").unwrap_or(None).map(|v| v.val);
603+
let cfg = self.get::<TermConfig>("term").unwrap_or_default();
599604

600-
let color = color.as_ref().or_else(|| cfg_color.as_ref());
605+
let color = color.as_ref().or_else(|| cfg.color.as_ref());
601606

602-
let verbosity = match (verbose, cfg_verbose, quiet) {
607+
let verbosity = match (verbose, cfg.verbose, quiet) {
603608
(Some(true), _, None) | (None, Some(true), None) => Verbosity::Verbose,
604609

605610
// Command line takes precedence over configuration, so ignore the

0 commit comments

Comments
 (0)