bug: fix panic if battery feature was disabled

This commit is contained in:
ClementTsang 2022-05-01 16:53:24 -04:00
parent 8cc361e443
commit a92313a5be
2 changed files with 9 additions and 9 deletions

View File

@ -392,7 +392,7 @@ use CPU (3) as the default instead.
.arg(use_old_network_legend) .arg(use_old_network_legend)
.arg(whole_word); .arg(whole_word);
let app = if cfg!(feature = "battery") { if cfg!(feature = "battery") {
let battery = Arg::new("battery") let battery = Arg::new("battery")
.long("battery") .long("battery")
.help("Shows the battery widget.") .help("Shows the battery widget.")
@ -402,7 +402,5 @@ use CPU (3) as the default instead.
app.arg(battery) app.arg(battery)
} else { } else {
app app
}; }
app
} }

View File

@ -916,11 +916,13 @@ fn get_hide_table_gap(matches: &clap::ArgMatches, config: &Config) -> bool {
} }
fn get_use_battery(matches: &clap::ArgMatches, config: &Config) -> bool { fn get_use_battery(matches: &clap::ArgMatches, config: &Config) -> bool {
if matches.is_present("battery") { if cfg!(feature = "battery") {
return true; if matches.is_present("battery") {
} else if let Some(flags) = &config.flags { return true;
if let Some(battery) = flags.battery { } else if let Some(flags) = &config.flags {
return battery; if let Some(battery) = flags.battery {
return battery;
}
} }
} }
false false