summaryrefslogtreecommitdiffstats
path: root/src/clap.rs
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2022-10-15 16:50:21 -0400
committerGitHub <noreply@github.com>2022-10-15 16:50:21 -0400
commita949740c942d69fba51b3cf3b5f1fd9dfc3a9c24 (patch)
tree54b1ef00831dbdbf0db7aef7780bee5b2bfcc200 /src/clap.rs
parentbd35bbdc9c539e035bc4bf91c799d85e566a6921 (diff)
other: make gpu memory collection configurable (#835)
Follow-up to #794, this makes GPU memory collection toggleable.
Diffstat (limited to 'src/clap.rs')
-rw-r--r--src/clap.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/clap.rs b/src/clap.rs
index a882d932..c24498f3 100644
--- a/src/clap.rs
+++ b/src/clap.rs
@@ -348,7 +348,8 @@ use CPU (3) as the default instead.
"Displays the network widget with binary prefixes (i.e. kibibits, mebibits) rather than a decimal prefix (i.e. kilobits, megabits). Defaults to decimal prefixes.",
);
- let app = Command::new(crate_name!())
+ #[allow(unused_mut)]
+ let mut app = Command::new(crate_name!())
.version(crate_version!())
.author(crate_authors!())
.about(crate_description!())
@@ -392,19 +393,27 @@ use CPU (3) as the default instead.
.arg(use_old_network_legend)
.arg(whole_word);
- if cfg!(feature = "battery") {
+ #[cfg(feature = "battery")]
+ {
let battery = Arg::new("battery")
.long("battery")
.help("Shows the battery widget.")
.long_help(
"Shows the battery widget in default or basic mode. No effect on custom layouts.",
);
- app.arg(battery)
- } else {
- app
+ app = app.arg(battery);
+ }
+
+ #[cfg(feature = "gpu")]
+ {
+ let enable_gpu_memory = Arg::new("enable_gpu_memory")
+ .long("enable_gpu_memory")
+ .help("Enable collecting and displaying GPU memory usage.");
+ app = app.arg(enable_gpu_memory);
}
-}
+ app
+}
#[cfg(test)]
mod test {
use super::*;