mirror of
https://github.com/ClementTsang/bottom.git
synced 2024-09-11 03:35:35 +03:00
bug: fix default_cpu_entry arg not being used and missing from docs (#1543)
This commit is contained in:
parent
9f7e00497d
commit
feb0c6912c
@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Bug Fixes
|
||||
|
||||
- [#1541](https://github.com/ClementTsang/bottom/pull/1541): Fix some process details not updating for macOS and Windows.
|
||||
- [#1543](https://github.com/ClementTsang/bottom/pull/1543): Fix the `--default_cpu_entry` argument not being checked.
|
||||
|
||||
## [0.10.1] - 2024-08-01
|
||||
|
||||
|
@ -48,27 +48,28 @@ see information on these options by running `btm -h`, or run `btm --help` to dis
|
||||
|
||||
## CPU Options
|
||||
|
||||
| Option | Behaviour |
|
||||
| -------------------- | ------------------------------------------- |
|
||||
| `--cpu_left_legend` | Puts the CPU chart legend on the left side. |
|
||||
| `-a, --hide_avg_cpu` | Hides the average CPU usage entry. |
|
||||
| Option | Behaviour |
|
||||
| --------------------- | ------------------------------------------------- |
|
||||
| `--cpu_left_legend` | Puts the CPU chart legend on the left side. |
|
||||
| `--default_cpu_entry` | Sets which CPU entry type is selected by default. |
|
||||
| `-a, --hide_avg_cpu` | Hides the average CPU usage entry. |
|
||||
|
||||
## Memory Options
|
||||
|
||||
| Option | Behaviour |
|
||||
| ---------------------------- | --------------------------------------------------------- |
|
||||
| `--enable_cache_memory` | Enable collecting and displaying cache and buffer memory. |
|
||||
| `--memory_legend <POSITION>` | Where to place the legend for the memory chart widget. |
|
||||
| `--enable_cache_memory` | Enable collecting and displaying cache and buffer memory. |
|
||||
|
||||
## Network Options
|
||||
|
||||
| Option | Behaviour |
|
||||
| ----------------------------- | ------------------------------------------------------- |
|
||||
| `--network_legend <POSITION>` | Where to place the legend for the network chart widget. |
|
||||
| `--network_use_binary_prefix` | Displays the network widget with binary prefixes. |
|
||||
| `--network_use_bytes` | Displays the network widget using bytes. |
|
||||
| `--network_use_binary_prefix` | Displays the network widget with binary prefixes. |
|
||||
| `--network_use_log` | Displays the network widget with a log scale. |
|
||||
| `--use_old_network_legend` | (DEPRECATED) Uses a separated network legend. |
|
||||
| `--use_old_network_legend` | (DEPRECATED) Uses a separate network legend. |
|
||||
|
||||
## Battery Options
|
||||
|
||||
@ -84,9 +85,9 @@ see information on these options by running `btm -h`, or run `btm --help` to dis
|
||||
|
||||
## Style Options
|
||||
|
||||
| Option | Behaviour |
|
||||
| ------------------------ | ------------------------------------------ |
|
||||
| `--theme <COLOR SCHEME>` | Use a color scheme, use `--help` for info. |
|
||||
| Option | Behaviour |
|
||||
| ------------------ | ---------------------------------------------------------------- |
|
||||
| `--theme <SCHEME>` | Use a built-in color theme, use '--help' for info on the colors. |
|
||||
|
||||
## Other Options
|
||||
|
||||
|
@ -50,4 +50,4 @@ each time:
|
||||
| `expanded` | Boolean | Expand the default widget upon starting the app. |
|
||||
| `memory_legend` | String (one of ["none", "top-left", "top", "top-right", "left", "right", "bottom-left", "bottom", "bottom-right"]) | Where to place the legend for the memory widget. |
|
||||
| `network_legend` | String (one of ["none", "top-left", "top", "top-right", "left", "right", "bottom-left", "bottom", "bottom-right"]) | Where to place the legend for the network widget. |
|
||||
| `average_cpu_row` | Boolean | Moves the average CPU usage entry to its own row when using basic mode. |
|
||||
| `average_cpu_row` | Boolean | Moves the average CPU usage entry to its own row when using basic mode. |
|
||||
|
@ -197,6 +197,9 @@ pub(crate) fn init_app(
|
||||
let is_advanced_kill = !(is_flag_enabled!(disable_advanced_kill, args.process, config));
|
||||
let process_memory_as_value = is_flag_enabled!(process_memory_as_value, args.process, config);
|
||||
|
||||
// For CPU
|
||||
let default_cpu_selection = get_default_cpu_selection(args, config);
|
||||
|
||||
let mut widget_map = HashMap::new();
|
||||
let mut cpu_state_map: HashMap<u64, CpuWidgetState> = HashMap::new();
|
||||
let mut mem_state_map: HashMap<u64, MemWidgetState> = HashMap::new();
|
||||
@ -269,7 +272,7 @@ pub(crate) fn init_app(
|
||||
network_unit_type,
|
||||
network_use_binary_prefix,
|
||||
retention_ms,
|
||||
dedicated_average_row: get_dedicated_avg_row(args, config),
|
||||
dedicated_average_row: get_dedicated_avg_row(config),
|
||||
};
|
||||
|
||||
let table_config = ProcTableConfig {
|
||||
@ -324,11 +327,7 @@ pub(crate) fn init_app(
|
||||
widget.widget_id,
|
||||
CpuWidgetState::new(
|
||||
&app_config_fields,
|
||||
config
|
||||
.cpu
|
||||
.as_ref()
|
||||
.map(|cfg| cfg.default)
|
||||
.unwrap_or_default(),
|
||||
default_cpu_selection,
|
||||
default_time_value,
|
||||
autohide_timer,
|
||||
&styling,
|
||||
@ -678,14 +677,24 @@ fn get_show_average_cpu(args: &BottomArgs, config: &Config) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn get_dedicated_avg_row(_args: &BottomArgs, config: &Config) -> bool {
|
||||
// I hate this too.
|
||||
fn get_default_cpu_selection(args: &BottomArgs, config: &Config) -> config::cpu::CpuDefault {
|
||||
match &args.cpu.default_cpu_entry {
|
||||
Some(default) => match default {
|
||||
args::CpuDefault::All => config::cpu::CpuDefault::All,
|
||||
args::CpuDefault::Average => config::cpu::CpuDefault::Average,
|
||||
},
|
||||
None => config.cpu.as_ref().map(|c| c.default).unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_dedicated_avg_row(config: &Config) -> bool {
|
||||
let conf = config
|
||||
.flags
|
||||
.as_ref()
|
||||
.and_then(|flags| flags.average_cpu_row)
|
||||
.unwrap_or(false);
|
||||
|
||||
// args.cpu.average_cpu_row || conf
|
||||
conf
|
||||
}
|
||||
|
||||
|
@ -408,18 +408,6 @@ impl ValueEnum for CpuDefault {
|
||||
#[derive(Args, Clone, Debug, Default)]
|
||||
#[command(next_help_heading = "CPU Options", rename_all = "snake_case")]
|
||||
pub struct CpuArgs {
|
||||
#[arg(
|
||||
long,
|
||||
help = "Sets which CPU entry type is selected by default.",
|
||||
value_name = "ENTRY",
|
||||
value_parser = value_parser!(CpuDefault),
|
||||
default_value = "all"
|
||||
)]
|
||||
pub default_cpu_entry: CpuDefault,
|
||||
|
||||
#[arg(short = 'a', long, action = ArgAction::SetTrue, help = "Hides the average CPU usage entry.")]
|
||||
pub hide_avg_cpu: bool,
|
||||
|
||||
// TODO: Maybe rename this or fix this? Should this apply to all "left legends"?
|
||||
#[arg(
|
||||
short = 'l',
|
||||
@ -428,8 +416,17 @@ pub struct CpuArgs {
|
||||
help = "Puts the CPU chart legend on the left side."
|
||||
)]
|
||||
pub cpu_left_legend: bool,
|
||||
// #[arg(short = 'A', long, action = ArgAction::SetTrue, help = "Moves the average CPU usage entry to its own row when using basic mode.")]
|
||||
// pub average_cpu_row: bool,
|
||||
|
||||
#[arg(
|
||||
long,
|
||||
help = "Sets which CPU entry type is selected by default.",
|
||||
value_name = "ENTRY",
|
||||
value_parser = value_parser!(CpuDefault),
|
||||
)]
|
||||
pub default_cpu_entry: Option<CpuDefault>,
|
||||
|
||||
#[arg(short = 'a', long, action = ArgAction::SetTrue, help = "Hides the average CPU usage entry.")]
|
||||
pub hide_avg_cpu: bool,
|
||||
}
|
||||
|
||||
/// Memory argument/config options.
|
||||
|
Loading…
Reference in New Issue
Block a user