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.")
@ -401,8 +401,6 @@ use CPU (3) as the default instead.
); );
app.arg(battery) app.arg(battery)
} else { } else {
app
};
app app
} }
}

View File

@ -916,6 +916,7 @@ 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 cfg!(feature = "battery") {
if matches.is_present("battery") { if matches.is_present("battery") {
return true; return true;
} else if let Some(flags) = &config.flags { } else if let Some(flags) = &config.flags {
@ -923,6 +924,7 @@ fn get_use_battery(matches: &clap::ArgMatches, config: &Config) -> bool {
return battery; return battery;
} }
} }
}
false false
} }