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(whole_word);
let app = if cfg!(feature = "battery") {
if cfg!(feature = "battery") {
let battery = Arg::new("battery")
.long("battery")
.help("Shows the battery widget.")
@ -402,7 +402,5 @@ use CPU (3) as the default instead.
app.arg(battery)
} else {
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 {
if matches.is_present("battery") {
return true;
} else if let Some(flags) = &config.flags {
if let Some(battery) = flags.battery {
return battery;
if cfg!(feature = "battery") {
if matches.is_present("battery") {
return true;
} else if let Some(flags) = &config.flags {
if let Some(battery) = flags.battery {
return battery;
}
}
}
false