mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-21 19:53:05 +00:00
refactor: rename flags.enable_gpu
to flags.disable_gpu
(false
by default) (#1559)
Co-authored-by: shurizzle <me@shurizzle.dev>
This commit is contained in:
parent
1f011bd918
commit
6b0a285541
6 changed files with 19 additions and 18 deletions
|
@ -330,7 +330,7 @@
|
|||
"null"
|
||||
]
|
||||
},
|
||||
"enable_gpu": {
|
||||
"disable_gpu": {
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
|
|
|
@ -330,8 +330,8 @@ pub(crate) const CONFIG_TEXT: &str = r#"# This is a default config file for bott
|
|||
#network_use_log = false
|
||||
# Hides advanced options to stop a process on Unix-like systems.
|
||||
#disable_advanced_kill = false
|
||||
# Shows GPU(s) information
|
||||
#enable_gpu = false
|
||||
# Hide GPU(s) information
|
||||
#disable_gpu = false
|
||||
# Shows cache and buffer memory
|
||||
#enable_cache_memory = false
|
||||
# How much data is stored at once in terms of time.
|
||||
|
|
|
@ -806,19 +806,20 @@ fn get_use_battery(args: &BottomArgs, config: &Config) -> bool {
|
|||
false
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[cfg(feature = "gpu")]
|
||||
fn get_enable_gpu(args: &BottomArgs, config: &Config) -> bool {
|
||||
#[cfg(feature = "gpu")]
|
||||
{
|
||||
if args.gpu.enable_gpu {
|
||||
return true;
|
||||
} else if let Some(flags) = &config.flags {
|
||||
if let Some(enable_gpu) = flags.enable_gpu {
|
||||
return enable_gpu;
|
||||
}
|
||||
}
|
||||
if args.gpu.disable_gpu {
|
||||
return false;
|
||||
}
|
||||
!config
|
||||
.flags
|
||||
.as_ref()
|
||||
.and_then(|f| f.disable_gpu)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
fn get_enable_gpu(_: &BottomArgs, _: &Config) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
|
|
|
@ -520,8 +520,8 @@ pub struct BatteryArgs {
|
|||
#[derive(Args, Clone, Debug, Default)]
|
||||
#[command(next_help_heading = "GPU Options", rename_all = "snake_case")]
|
||||
pub struct GpuArgs {
|
||||
#[arg(long, action = ArgAction::SetTrue, help = "Enable collecting and displaying GPU usage.")]
|
||||
pub enable_gpu: bool,
|
||||
#[arg(long, action = ArgAction::SetTrue, help = "Disable collecting and displaying GPU usage.")]
|
||||
pub disable_gpu: bool,
|
||||
}
|
||||
|
||||
/// Style arguments/config options.
|
||||
|
|
|
@ -40,7 +40,7 @@ pub(crate) struct FlagConfig {
|
|||
pub(crate) network_use_bytes: Option<bool>,
|
||||
pub(crate) network_use_log: Option<bool>,
|
||||
pub(crate) network_use_binary_prefix: Option<bool>,
|
||||
pub(crate) enable_gpu: Option<bool>,
|
||||
pub(crate) disable_gpu: Option<bool>,
|
||||
pub(crate) enable_cache_memory: Option<bool>,
|
||||
pub(crate) retention: Option<StringOrNum>,
|
||||
pub(crate) average_cpu_row: Option<bool>,
|
||||
|
|
|
@ -157,11 +157,11 @@ fn test_battery_flag() {
|
|||
#[cfg_attr(feature = "gpu", ignore)]
|
||||
fn test_gpu_flag() {
|
||||
no_cfg_btm_command()
|
||||
.arg("--enable_gpu")
|
||||
.arg("--disable_gpu")
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(predicate::str::contains(
|
||||
"unexpected argument '--enable_gpu' found",
|
||||
"unexpected argument '--disable_gpu' found",
|
||||
));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue