diff options
author | ClementTsang <cjhtsang@uwaterloo.ca> | 2022-05-01 16:53:24 -0400 |
---|---|---|
committer | ClementTsang <cjhtsang@uwaterloo.ca> | 2022-05-01 16:57:03 -0400 |
commit | a92313a5be33d556b8a5df3d9c4aada3bb839fc4 (patch) | |
tree | a162d90b799b06d489a7f36b287eb136957eeb1d /src | |
parent | 8cc361e443aaebe804df0c2cbe3e2e7d3b22057a (diff) |
bug: fix panic if battery feature was disabled
Diffstat (limited to 'src')
-rw-r--r-- | src/clap.rs | 6 | ||||
-rw-r--r-- | src/options.rs | 12 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/clap.rs b/src/clap.rs index 8926d6bd..0fbd3223 100644 --- a/src/clap.rs +++ b/src/clap.rs @@ -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 + } } diff --git a/src/options.rs b/src/options.rs index b7377e6e..1bebd502 100644 --- a/src/options.rs +++ b/src/options.rs @@ -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 |