other: update a bunch of argument descriptions and some arg/config names (#1441)

* other: update a bunch of argument descriptions and some arg/config names

* update docs

* changelog
This commit is contained in:
Clement Tsang 2024-04-11 00:46:35 +00:00 committed by GitHub
parent bb0bc8a0b0
commit 93d6718766
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 343 additions and 375 deletions

View File

@ -19,6 +19,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#1376](https://github.com/ClementTsang/bottom/pull/1376): Group together related command-line arguments in `-h` and `--help`. - [#1376](https://github.com/ClementTsang/bottom/pull/1376): Group together related command-line arguments in `-h` and `--help`.
- [#1411](https://github.com/ClementTsang/bottom/pull/1411): Add `time` as a default column. - [#1411](https://github.com/ClementTsang/bottom/pull/1411): Add `time` as a default column.
- [#1436](https://github.com/ClementTsang/bottom/pull/1436): Use actual "swap" value for Windows. - [#1436](https://github.com/ClementTsang/bottom/pull/1436): Use actual "swap" value for Windows.
- [#1441](https://github.com/ClementTsang/bottom/pull/1441): The following arguments have changed names:
- `--left_legend/-l` is now `--cpu_left_legend`.
- [#1441](https://github.com/ClementTsang/bottom/pull/1441): The following config arguments have changed names:
- `expanded_on_startup` is now `expanded`.
- `left_legend` is now `cpu_left_legend`.
### Bug Fixes ### Bug Fixes

View File

@ -5,76 +5,76 @@ see information on these options by running `btm -h`, or run `btm --help` to dis
## General Options ## General Options
| Option | Behaviour | | Option | Behaviour |
| ------------------------------------- | --------------------------------------------------- | | --------------------------------- | ---------------------------------------------------- |
| `--autohide_time` | Temporarily shows the time scale in graphs. | | `--autohide_time` | Temporarily shows the time scale in graphs. |
| `-b`, `--basic` | Hides graphs and uses a more basic look. | | `-b, --basic` | Hides graphs and uses a more basic look. |
| `-C`, `--config <CONFIG PATH>` | Sets the location of the config file. | | `-C, --config <CONFIG PATH>` | Sets the location of the config file. |
| `-t`, `--default_time_value <TIME>` | Default time value for graphs. | | `-t, --default_time_value <TIME>` | Default time value for graphs. |
| `--default_widget_count <INT>` | Sets the n'th selected widget type as the default. | | `--default_widget_count <N>` | Sets the N'th selected widget type as the default. |
| `--default_widget_type <WIDGET TYPE>` | Sets the default widget type, use --help for info. | | `--default_widget_type <WIDGET>` | Sets the default widget type, use `--help` for info. |
| `--disable_click` | Disables mouse clicks. | | `--disable_click` | Disables mouse clicks. |
| `-m`, `--dot_marker` | Uses a dot marker for graphs. | | `-m, --dot_marker` | Uses a dot marker for graphs. |
| `-e`, `--expanded` | Expand the default widget upon starting the app. | | `-e, --expanded` | Expand the default widget upon starting the app. |
| `--hide_table_gap` | Hides spacing between table headers and entries. | | `--hide_table_gap` | Hides spacing between table headers and entries. |
| `--hide_time` | Hides the time scale. | | `--hide_time` | Hides the time scale from being shown. |
| `-l`, `--left_legend` | Puts the CPU chart legend to the left side. | | `-r, --rate <TIME>` | Sets how often data is refreshed. |
| `-r`, `--rate <TIME>` | Sets the data refresh rate. | | `--retention <TIME>` | How far back data will be stored up to. |
| `--retention <TIME>` | The timespan of data stored. | | `--show_table_scroll_position` | Shows the scroll position tracker in table widgets. |
| `--show_table_scroll_position` | Shows the scroll position tracker in table widgets. | | `-d, --time_delta <TIME>` | The amount of time changed upon zooming. |
| `-d`, `--time_delta <TIME>` | The amount of time changed upon zooming. |
## Process Options ## Process Options
| Option | Behaviour | | Option | Behaviour |
| -------------------------- | --------------------------------------------------------------------- | | ------------------------- | -------------------------------------------------------------------------------------- |
| `-S`, `--case_sensitive` | Enables case sensitivity by default. | | `-S, --case_sensitive` | Enables case sensitivity by default. |
| `-u`, `--current_usage` | Sets process CPU% to be based on current CPU%. | | `-u, --current_usage` | Calculates process CPU usage as a percentage of current usage rather than total usage. |
| `--disable_advanced_kill` | Hides advanced process killing. | | `--disable_advanced_kill` | Hides additional stopping options Unix-like systems. |
| `-g`, `--group_processes` | Groups processes with the same name by default. | | `-g, --group_processes` | Groups processes with the same name by default. |
| `--process_command` | Show processes as their commands by default. | | `--mem_as_value` | Defaults to showing process memory usage by value. |
| `-R`, `--regex` | Enables regex by default. | | `--process_command` | Shows the full command name instead of the process name by default. |
| `-T`, `--tree` | Defaults the process widget be in tree mode. | | `-R, --regex` | Enables regex by default while searching. |
| `-n`, `--unnormalized_cpu` | Show process CPU% usage without normalizing over the number of cores. | | `-T, --tree` | Makes the process widget use tree mode by default. |
| `-W`, `--whole_word` | Enables whole-word matching by default. | | `-n, --unnormalized_cpu` | Show process CPU% usage without averaging over the number of CPU cores. |
| `-W, --whole_word` | Enables whole-word matching by default while searching. |
## Temperature Options ## Temperature Options
| Option | Behaviour | | Option | Behaviour |
| -------------------- | --------------------------------------- | | ------------------ | --------------------------------------------- |
| `-c`, `--celsius` | Use Celsius as the temperature unit. | | `-c, --celsius` | Use Celsius as the temperature unit. Default. |
| `-f`, `--fahrenheit` | Use Fahrenheit as the temperature unit. | | `-f, --fahrenheit` | Use Fahrenheit as the temperature unit. |
| `-k`, `--kelvin` | Use Kelvin as the temperature unit. | | `-k, --kelvin` | Use Kelvin as the temperature unit. |
## CPU Options ## CPU Options
| Option | Behaviour | | Option | Behaviour |
| ---------------------- | ---------------------------- | | -------------------- | ------------------------------------------- |
| `-a`, `--hide_avg_cpu` | Hides the average CPU usage. | | `--cpu_left_legend` | Puts the CPU chart legend on the left side. |
| `-a, --hide_avg_cpu` | Hides the average CPU usage entry. |
## Memory Options ## Memory Options
| Option | Behaviour | | Option | Behaviour |
| ----------------------- | --------------------------------------------------------- | | ---------------------------- | --------------------------------------------------------- |
| `--enable_cache_memory` | Enable collecting and displaying cache and buffer memory. | | `--enable_cache_memory` | Enable collecting and displaying cache and buffer memory. |
| `--mem_as_value` | Defaults to showing process memory usage by value. | | `--memory_legend <POSITION>` | Where to place the legend for the memory chart widget. |
| `--memory_legend` | Where to place the legend for the memory widget. |
## Network Options ## Network Options
| Option | Behaviour | | Option | Behaviour |
| ----------------------------- | ------------------------------------------------- | | ----------------------------- | ------------------------------------------------------- |
| `--network_use_binary_prefix` | Displays the network widget with binary prefixes. | | `--network_legend <POSITION>` | Where to place the legend for the network chart widget. |
| `--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. | | `--network_use_bytes` | Displays the network widget using bytes. |
| `--network_legend` | Where to place the legend for the network widget. | | `--network_use_log` | Displays the network widget with a log scale. |
| `--use_old_network_legend` | DEPRECATED - uses a separate network legend. | | `--use_old_network_legend` | (DEPRECATED) Uses a separated network legend. |
## Battery Options ## Battery Options
| Option | Behaviour | | Option | Behaviour |
| ----------- | ------------------------- | | ----------- | ----------------------------------------------- |
| `--battery` | Shows the battery widget. | | `--battery` | Shows the battery widget in non-custom layouts. |
## GPU Options ## GPU Options
@ -84,13 +84,13 @@ see information on these options by running `btm -h`, or run `btm --help` to dis
## Style Options ## Style Options
| Option | Behaviour | | Option | Behaviour |
| ------------------------ | ---------------------------------------- | | ------------------------ | ------------------------------------------ |
| `--color <COLOR SCHEME>` | Use a color scheme, use --help for info. | | `--color <COLOR SCHEME>` | Use a color scheme, use `--help` for info. |
## Other Options ## Other Options
| Option | Behaviour | | Option | Behaviour |
| ----------------- | ------------------------------------------ | | ----------------- | ------------------------------------------------- |
| `-h`, `--help` | Prints help (see more info with '--help'). | | `-h`, `--help` | Prints help info (for more details use `--help`.) |
| `-V`, `--version` | Prints version information. | | `-V`, `--version` | Prints version information. |

View File

@ -11,7 +11,7 @@ each time:
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------- | | ---------------------------- | ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------- |
| `hide_avg_cpu` | Boolean | Hides the average CPU usage. | | `hide_avg_cpu` | Boolean | Hides the average CPU usage. |
| `dot_marker` | Boolean | Uses a dot marker for graphs. | | `dot_marker` | Boolean | Uses a dot marker for graphs. |
| `left_legend` | Boolean | Puts the CPU chart legend to the left side. | | `cpu_left_legend` | Boolean | Puts the CPU chart legend to the left side. |
| `current_usage` | Boolean | Sets process CPU% to be based on current CPU%. | | `current_usage` | Boolean | Sets process CPU% to be based on current CPU%. |
| `group_processes` | Boolean | Groups processes with the same name by default. | | `group_processes` | Boolean | Groups processes with the same name by default. |
| `case_sensitive` | Boolean | Enables case sensitivity by default. | | `case_sensitive` | Boolean | Enables case sensitivity by default. |
@ -41,6 +41,6 @@ each time:
| `enable_gpu` | Boolean | Shows the GPU widgets. | | `enable_gpu` | Boolean | Shows the GPU widgets. |
| `retention` | String (human readable time, such as "10m", "1h", etc.) | How much data is stored at once in terms of time. | | `retention` | String (human readable time, such as "10m", "1h", etc.) | How much data is stored at once in terms of time. |
| `unnormalized_cpu` | Boolean | Show process CPU% without normalizing over the number of cores. | | `unnormalized_cpu` | Boolean | Show process CPU% without normalizing over the number of cores. |
| `expanded_on_startup` | Boolean | Expand the default widget upon starting the app. | | `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. | | `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. | | `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. |

View File

@ -14,7 +14,7 @@
# The update rate of the application. # The update rate of the application.
#rate = "1s" #rate = "1s"
# Whether to put the CPU legend to the left. # Whether to put the CPU legend to the left.
#left_legend = false #cpu_left_legend = false
# Whether to set CPU% on a process to be based on the total CPU or just current usage. # Whether to set CPU% on a process to be based on the total CPU or just current usage.
#current_usage = false #current_usage = false
# Whether to set CPU% on a process to be based on the total CPU or per-core CPU% (not divided by the number of cpus). # Whether to set CPU% on a process to be based on the total CPU or per-core CPU% (not divided by the number of cpus).
@ -44,7 +44,7 @@
#default_widget_type = "proc" #default_widget_type = "proc"
#default_widget_count = 1 #default_widget_count = 1
# Expand selected widget upon starting the app # Expand selected widget upon starting the app
#expanded_on_startup = true #expanded = true
# Use basic mode # Use basic mode
#basic = false #basic = false
# Use the old network legend style # Use the old network legend style

View File

@ -5,7 +5,7 @@ avg_cpu = true
temperature_type = "c" temperature_type = "c"
rate = 1000 rate = 1000
left_legend = false cpu_left_legend = false
current_usage = false current_usage = false
group_processes = false group_processes = false
case_sensitive = false case_sensitive = false

View File

@ -75,7 +75,7 @@
"description": "The update rate of the application", "description": "The update rate of the application",
"type": "integer" "type": "integer"
}, },
"left_legend": { "cpu_left_legend": {
"default": false, "default": false,
"description": "Whether to put the CPU legend to the left", "description": "Whether to put the CPU legend to the left",
"type": "boolean" "type": "boolean"
@ -141,7 +141,7 @@
"description": "Override layout default widget", "description": "Override layout default widget",
"type": "integer" "type": "integer"
}, },
"expanded_on_startup": { "expanded": {
"default": true, "default": true,
"description": "Expand selected widget upon starting the app", "description": "Expand selected widget upon starting the app",
"type": "boolean" "type": "boolean"

View File

@ -47,7 +47,7 @@ pub struct AppConfigFields {
pub update_rate: u64, pub update_rate: u64,
pub temperature_type: temperature::TemperatureType, pub temperature_type: temperature::TemperatureType,
pub use_dot: bool, pub use_dot: bool,
pub left_legend: bool, pub cpu_left_legend: bool,
pub show_average_cpu: bool, // TODO: Unify this in CPU options pub show_average_cpu: bool, // TODO: Unify this in CPU options
pub use_current_cpu_total: bool, pub use_current_cpu_total: bool,
pub unnormalized_cpu: bool, pub unnormalized_cpu: bool,
@ -1835,7 +1835,7 @@ impl App {
} }
} }
} }
} else if self.app_config_fields.left_legend { } else if self.app_config_fields.cpu_left_legend {
if let BottomWidgetType::Cpu = self.current_widget.widget_type { if let BottomWidgetType::Cpu = self.current_widget.widget_type {
if let Some(current_widget) = self.widget_map.get(&self.current_widget.widget_id) { if let Some(current_widget) = self.widget_map.get(&self.current_widget.widget_id) {
if let Some(cpu_widget_state) = self if let Some(cpu_widget_state) = self
@ -1872,7 +1872,7 @@ impl App {
self.current_widget = proc_sort_widget.clone(); self.current_widget = proc_sort_widget.clone();
} }
} }
} else if self.app_config_fields.left_legend { } else if self.app_config_fields.cpu_left_legend {
if let BottomWidgetType::CpuLegend = self.current_widget.widget_type { if let BottomWidgetType::CpuLegend = self.current_widget.widget_type {
if let Some(current_widget) = self.widget_map.get(&self.current_widget.widget_id) { if let Some(current_widget) = self.widget_map.get(&self.current_widget.widget_id) {
if let Some(new_widget_id) = current_widget.right_neighbour { if let Some(new_widget_id) = current_widget.right_neighbour {

View File

@ -30,7 +30,7 @@ impl Painter {
if legend_width < 6 { if legend_width < 6 {
// Skip drawing legend // Skip drawing legend
if app_state.current_widget.widget_id == (widget_id + 1) { if app_state.current_widget.widget_id == (widget_id + 1) {
if app_state.app_config_fields.left_legend { if app_state.app_config_fields.cpu_left_legend {
app_state.move_widget_selection(&WidgetDirection::Right); app_state.move_widget_selection(&WidgetDirection::Right);
} else { } else {
app_state.move_widget_selection(&WidgetDirection::Left); app_state.move_widget_selection(&WidgetDirection::Left);
@ -54,7 +54,7 @@ impl Painter {
} else { } else {
let graph_width = draw_loc.width - legend_width; let graph_width = draw_loc.width - legend_width;
let (graph_index, legend_index, constraints) = let (graph_index, legend_index, constraints) =
if app_state.app_config_fields.left_legend { if app_state.app_config_fields.cpu_left_legend {
( (
1, 1,
0, 0,

View File

@ -532,7 +532,7 @@ pub const CONFIG_TEXT: &str = r#"# This is a default config file for bottom. Al
# The update rate of the application. # The update rate of the application.
#rate = "1s" #rate = "1s"
# Whether to put the CPU legend to the left. # Whether to put the CPU legend to the left.
#left_legend = false #cpu_left_legend = false
# Whether to set CPU% on a process to be based on the total CPU or just current usage. # Whether to set CPU% on a process to be based on the total CPU or just current usage.
#current_usage = false #current_usage = false
# Whether to set CPU% on a process to be based on the total CPU or per-core CPU% (not divided by the number of cpus). # Whether to set CPU% on a process to be based on the total CPU or per-core CPU% (not divided by the number of cpus).
@ -562,7 +562,7 @@ pub const CONFIG_TEXT: &str = r#"# This is a default config file for bottom. Al
#default_widget_type = "proc" #default_widget_type = "proc"
#default_widget_count = 1 #default_widget_count = 1
# Expand selected widget upon starting the app # Expand selected widget upon starting the app
#expanded_on_startup = true #expanded = true
# Use basic mode # Use basic mode
#basic = false #basic = false
# Use the old network legend style # Use the old network legend style

View File

@ -74,7 +74,7 @@ pub fn init_app(
.context("Update 'default_time_value' in your config file.")?; .context("Update 'default_time_value' in your config file.")?;
let use_basic_mode = is_flag_enabled!(basic, matches, config); let use_basic_mode = is_flag_enabled!(basic, matches, config);
let expanded_upon_startup = is_flag_enabled!(expanded_on_startup, matches, config); let expanded = is_flag_enabled!(expanded, matches, config);
// For processes // For processes
let is_grouped = is_flag_enabled!(group_processes, matches, config); let is_grouped = is_flag_enabled!(group_processes, matches, config);
@ -137,7 +137,7 @@ pub fn init_app(
.context("Update 'temperature_type' in your config file.")?, .context("Update 'temperature_type' in your config file.")?,
show_average_cpu: get_show_average_cpu(matches, config), show_average_cpu: get_show_average_cpu(matches, config),
use_dot: is_flag_enabled!(dot_marker, matches, config), use_dot: is_flag_enabled!(dot_marker, matches, config),
left_legend: is_flag_enabled!(left_legend, matches, config), cpu_left_legend: is_flag_enabled!(cpu_left_legend, matches, config),
use_current_cpu_total: is_flag_enabled!(current_usage, matches, config), use_current_cpu_total: is_flag_enabled!(current_usage, matches, config),
unnormalized_cpu: is_flag_enabled!(unnormalized_cpu, matches, config), unnormalized_cpu: is_flag_enabled!(unnormalized_cpu, matches, config),
use_basic_mode, use_basic_mode,
@ -346,7 +346,7 @@ pub fn init_app(
temp_filter, temp_filter,
net_filter, net_filter,
}; };
let is_expanded = expanded_upon_startup && !use_basic_mode; let is_expanded = expanded && !use_basic_mode;
Ok(App::new( Ok(App::new(
app_config_fields, app_config_fields,
@ -362,7 +362,7 @@ pub fn init_app(
pub fn get_widget_layout( pub fn get_widget_layout(
matches: &ArgMatches, config: &Config, matches: &ArgMatches, config: &Config,
) -> error::Result<(BottomLayout, u64, Option<BottomWidgetType>)> { ) -> error::Result<(BottomLayout, u64, Option<BottomWidgetType>)> {
let left_legend = is_flag_enabled!(left_legend, matches, config); let cpu_left_legend = is_flag_enabled!(cpu_left_legend, matches, config);
let (default_widget_type, mut default_widget_count) = let (default_widget_type, mut default_widget_count) =
get_default_widget_and_count(matches, config)?; get_default_widget_and_count(matches, config)?;
@ -402,7 +402,7 @@ pub fn get_widget_layout(
&mut default_widget_id, &mut default_widget_id,
&default_widget_type, &default_widget_type,
&mut default_widget_count, &mut default_widget_count,
left_legend, cpu_left_legend,
) )
}) })
.collect::<error::Result<Vec<_>>>()?, .collect::<error::Result<Vec<_>>>()?,

View File

@ -41,6 +41,18 @@ macro_rules! args {
}; };
} }
const CHART_WIDGET_POSITIONS: [&str; 9] = [
"none",
"top-left",
"top",
"top-right",
"left",
"right",
"bottom-left",
"bottom",
"bottom-right",
];
fn general_args(cmd: Command) -> Command { fn general_args(cmd: Command) -> Command {
let cmd = cmd.next_help_heading("General Options"); let cmd = cmd.next_help_heading("General Options");
@ -49,9 +61,8 @@ fn general_args(cmd: Command) -> Command {
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.help("Temporarily shows the time scale in graphs.") .help("Temporarily shows the time scale in graphs.")
.long_help( .long_help(
"Automatically hides the time scale in graphs after being shown for \ "Automatically hides the time scale in graphs after being shown for a brief moment when zoomed \
a brief moment when zoomed in/out. If time is disabled via --hide_time \ in/out. If time is disabled via --hide_time then this will have no effect."
then this will have no effect.",
); );
let basic = Arg::new("basic") let basic = Arg::new("basic")
@ -59,47 +70,7 @@ fn general_args(cmd: Command) -> Command {
.long("basic") .long("basic")
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.help("Hides graphs and uses a more basic look.") .help("Hides graphs and uses a more basic look.")
.long_help( .long_help("Hides graphs and uses a more basic look, largely inspired by htop's design.");
"Hides graphs and uses a more basic look. Design is largely inspired by htop's.",
);
let disable_click = Arg::new("disable_click")
.long("disable_click")
.action(ArgAction::SetTrue)
.help("Disables mouse clicks.")
.long_help("Disables mouse clicks from interacting with the program.");
let dot_marker = Arg::new("dot_marker")
.short('m')
.long("dot_marker")
.action(ArgAction::SetTrue)
.help("Uses a dot marker for graphs.")
.long_help("Uses a dot marker for graphs as opposed to the default braille marker.");
let hide_table_gap = Arg::new("hide_table_gap")
.long("hide_table_gap")
.action(ArgAction::SetTrue)
.help("Hides spacing between table headers and entries.")
.long_help("Hides the spacing between table headers and entries.");
let hide_time = Arg::new("hide_time")
.long("hide_time")
.action(ArgAction::SetTrue)
.help("Hides the time scale.")
.long_help("Completely hides the time scale from being shown.");
let left_legend = Arg::new("left_legend")
.short('l')
.long("left_legend")
.action(ArgAction::SetTrue)
.help("Puts the CPU chart legend to the left side.")
.long_help("Puts the CPU chart legend to the left side rather than the right side.");
let show_table_scroll_position = Arg::new("show_table_scroll_position")
.long("show_table_scroll_position")
.action(ArgAction::SetTrue)
.help("Shows the scroll position tracker in table widgets.")
.long_help("Shows the list scroll position tracker in the widget title for table widgets.");
let config_location = Arg::new("config_location") let config_location = Arg::new("config_location")
.short('C') .short('C')
@ -108,8 +79,9 @@ fn general_args(cmd: Command) -> Command {
.value_name("CONFIG PATH") .value_name("CONFIG PATH")
.help("Sets the location of the config file.") .help("Sets the location of the config file.")
.long_help( .long_help(
"Sets the location of the config file. Expects a config file in the TOML format.\ "Sets the location of the config file. Expects a config file in the TOML format. \
If it doesn't exist, one is created.", If it doesn't exist, a default config file is created at the path. If no path is provided, \
the default config location will be used."
) )
.value_hint(ValueHint::AnyPath); .value_hint(ValueHint::AnyPath);
@ -120,8 +92,8 @@ fn general_args(cmd: Command) -> Command {
.value_name("TIME") .value_name("TIME")
.help("Default time value for graphs.") .help("Default time value for graphs.")
.long_help( .long_help(
"Default time value for graphs. Takes a number in milliseconds or a human \ "Default time value for graphs. Either a number in milliseconds or a 'human duration' \
duration (e.g. 60s). The minimum time is 30s, and the default is 60s.", (e.g. 60s, 10m). Defaults to 60s, must be at least 30s.",
); );
// TODO: Charts are broken in the manpage // TODO: Charts are broken in the manpage
@ -129,31 +101,29 @@ fn general_args(cmd: Command) -> Command {
.long("default_widget_count") .long("default_widget_count")
.action(ArgAction::Set) .action(ArgAction::Set)
.requires_all(["default_widget_type"]) .requires_all(["default_widget_type"])
.value_name("INT") .value_name("N")
.help("Sets the n'th selected widget type as the default.") .help("Sets the N'th selected widget type as the default.")
.long_help(indoc! { .long_help(indoc! {
"Sets the n'th selected widget type to use as the default widget. "Sets the N'th selected widget type to use as the default widget. Requires 'default_widget_type' to also be \
Requires 'default_widget_type' to also be set, and defaults to 1. set, and defaults to 1.
This reads from left to right, top to bottom. For example, suppose This reads from left to right, top to bottom. For example, suppose we have a layout that looks like:
we have a layout that looks like:
+-------------------+-----------------------+ +-------------------+-----------------------+
| CPU (1) | CPU (2) | | CPU (1) | CPU (2) |
+---------+---------+-------------+---------+ +---------+---------+-------------+---------+
| Process | CPU (3) | Temperature | CPU (4) | | Process | CPU (3) | Temperature | CPU (4) |
+---------+---------+-------------+---------+ +---------+---------+-------------+---------+
And we set our default widget type to 'CPU'. If we set And we set our default widget type to 'CPU'. If we set '--default_widget_count 1', then it would use the \
'--default_widget_count 1', then it would use the CPU (1) as CPU (1) as the default widget. If we set '--default_widget_count 3', it would use CPU (3) as the default \
the default widget. If we set '--default_widget_count 3', it would instead."
use CPU (3) as the default instead."
}); });
let default_widget_type = Arg::new("default_widget_type") let default_widget_type = Arg::new("default_widget_type")
.long("default_widget_type") .long("default_widget_type")
.action(ArgAction::Set) .action(ArgAction::Set)
.value_name("WIDGET TYPE") .value_name("WIDGET")
.help("Sets the default widget type, use --help for info.") .help("Sets the default widget type, use `--help` for info.")
.long_help(indoc!{ .long_help(indoc!{
"Sets which widget type to use as the default widget. For the default \ "Sets which widget type to use as the default widget. For the default \
layout, this defaults to the 'process' widget. For a custom layout, it defaults \ layout, this defaults to the 'process' widget. For a custom layout, it defaults \
@ -166,7 +136,7 @@ fn general_args(cmd: Command) -> Command {
| Process | CPU (3) | Temperature | CPU (4) | | Process | CPU (3) | Temperature | CPU (4) |
+---------+---------+-------------+---------+ +---------+---------+-------------+---------+
Setting '--default_widget_type Temp' will make the temperature widget selected by default." Setting '--default_widget_type temperature' will make the temperature widget selected by default."
}) })
.value_parser([ .value_parser([
"cpu", "cpu",
@ -179,36 +149,73 @@ fn general_args(cmd: Command) -> Command {
"temp", "temp",
"temperature", "temperature",
"disk", "disk",
#[cfg(not(feature = "battery"))] #[cfg(feature = "battery")]
"batt", "batt",
#[cfg(not(feature = "battery"))] #[cfg(feature = "battery")]
"battery", "battery",
]); ]);
let expanded_on_startup = Arg::new("expanded_on_startup") let disable_click = Arg::new("disable_click")
.long("disable_click")
.action(ArgAction::SetTrue)
.help("Disables mouse clicks.")
.long_help("Disables mouse clicks from interacting with bottom.");
// TODO: Change this to accept a string with the type of marker.
let dot_marker = Arg::new("dot_marker")
.short('m')
.long("dot_marker")
.action(ArgAction::SetTrue)
.help("Uses a dot marker for graphs.")
.long_help("Uses a dot marker for graphs as opposed to the default braille marker.");
let expanded = Arg::new("expanded")
.short('e') .short('e')
.long("expanded") .long("expanded")
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.help("Expand the default widget upon starting the app.") .help("Expand the default widget upon starting the app.")
.long_help( .long_help("Expand the default widget upon starting the app. This flag has no effect in basic mode (--basic).");
"Expand the default widget upon starting the app. \
Same as pressing \"e\" inside the app. Use with \"default_widget_type\" \ let hide_table_gap = Arg::new("hide_table_gap")
and \"default_widget_count\" to select the desired expanded widget. This \ .long("hide_table_gap")
flag has no effect in basic mode (--basic).", .action(ArgAction::SetTrue)
); .help("Hides spacing between table headers and entries.");
let hide_time = Arg::new("hide_time")
.long("hide_time")
.action(ArgAction::SetTrue)
.help("Hides the time scale from being shown.");
let rate = Arg::new("rate") let rate = Arg::new("rate")
.short('r') .short('r')
.long("rate") .long("rate")
.action(ArgAction::Set) .action(ArgAction::Set)
.value_name("TIME") .value_name("TIME")
.help("Sets the data refresh rate.") .help("Sets how often data is refreshed.")
.long_help( .long_help(
"Sets the data refresh rate. Takes a number in milliseconds or a human\ "Sets how often data is refreshed. Either a number in milliseconds or a 'human duration' \
duration (e.g. 5s). The minimum is 250ms, and defaults to 1000ms. Smaller \ (e.g. 1s, 1m). Defaults to 1s, must be at least 250ms. Smaller values may result in \
values may take more computer resources.", higher system resource usage."
); );
// TODO: Unify how we do defaults.
let retention = Arg::new("retention")
.long("retention")
.action(ArgAction::Set)
.value_name("TIME")
.help("How far back data will be stored up to.")
.long_help(
"How far back data will be stored up to. Either a number in milliseconds or a 'human duration' \
(e.g. 10m, 1h). Defaults to 10 minutes, and must be at least 1 minute. Larger values \
may result in higher memory usage."
);
let show_table_scroll_position = Arg::new("show_table_scroll_position")
.long("show_table_scroll_position")
.action(ArgAction::SetTrue)
.help("Shows the scroll position tracker in table widgets.")
.long_help("Shows the list scroll position tracker in the widget title for table widgets.");
let time_delta = Arg::new("time_delta") let time_delta = Arg::new("time_delta")
.short('d') .short('d')
.long("time_delta") .long("time_delta")
@ -221,70 +228,107 @@ fn general_args(cmd: Command) -> Command {
defaults to 15s.", defaults to 15s.",
); );
// TODO: Unify how we do defaults.
let retention = Arg::new("retention")
.long("retention")
.action(ArgAction::Set)
.value_name("TIME")
.help("The timespan of data stored.")
.long_help(
"How much data is stored at once in terms of time. Takes a number \
in milliseconds or a human duration (e.g. 20m), with a minimum of 1 minute. \
Note that higher values will take up more memory. Defaults to 10 minutes.",
);
cmd.args(args![ cmd.args(args![
autohide_time, autohide_time,
basic, basic,
config_location,
default_widget_count,
default_time_value,
default_widget_type,
disable_click, disable_click,
dot_marker, dot_marker,
expanded,
hide_table_gap, hide_table_gap,
hide_time, hide_time,
left_legend,
show_table_scroll_position,
config_location,
default_time_value,
default_widget_count,
default_widget_type,
expanded_on_startup,
rate, rate,
time_delta,
retention, retention,
show_table_scroll_position,
time_delta,
]) ])
} }
fn style_args(cmd: Command) -> Command { fn process_args(cmd: Command) -> Command {
let cmd = cmd.next_help_heading("Style Options"); let cmd = cmd.next_help_heading("Process Options");
// TODO: File an issue with manpage, it cannot render charts correctly. let case_sensitive = Arg::new("case_sensitive")
let color = Arg::new("color") .short('S')
.long("color") .long("case_sensitive")
.action(ArgAction::Set) .action(ArgAction::SetTrue)
.value_name("COLOR SCHEME") .help("Enables case sensitivity by default.")
.value_parser([ .long_help("Enables case sensitivity by default when searching for a process.");
"default",
"default-light",
"gruvbox",
"gruvbox-light",
"nord",
"nord-light",
])
.hide_possible_values(true)
.help(
"Use a color scheme, use --help for info on the colors. \
[possible values: default, default-light, gruvbox, gruvbox-light, nord, nord-light]",
)
.long_help(indoc! {
"Use a pre-defined color scheme. Currently supported values are:
- default
- default-light (default but adjusted for lighter backgrounds)
- gruvbox (a bright theme with 'retro groove' colors)
- gruvbox-light (gruvbox but adjusted for lighter backgrounds)
- nord (an arctic, north-bluish color palette)
- nord-light (nord but adjusted for lighter backgrounds)"
});
cmd.arg(color) // TODO: Rename this.
let current_usage = Arg::new("current_usage")
.short('u')
.long("current_usage")
.action(ArgAction::SetTrue)
.help("Calculates process CPU usage as a percentage of current usage rather than total usage.");
// TODO: Disable this on Windows?
let disable_advanced_kill = Arg::new("disable_advanced_kill")
.long("disable_advanced_kill")
.action(ArgAction::SetTrue)
.help("Hides additional stopping options Unix-like systems.")
.long_help(
"Hides additional stopping options Unix-like systems. Signal 15 (TERM) will be sent when \
stopping a process.",
);
let group_processes = Arg::new("group_processes")
.short('g')
.long("group_processes")
.action(ArgAction::SetTrue)
.help("Groups processes with the same name by default.");
let mem_as_value = Arg::new("mem_as_value")
.long("mem_as_value")
.action(ArgAction::SetTrue)
.help("Defaults to showing process memory usage by value.")
.long_help("Defaults to showing process memory usage by value. Otherwise, it defaults to showing it by percentage.");
let process_command = Arg::new("process_command")
.long("process_command")
.action(ArgAction::SetTrue)
.help("Shows the full command name instead of the process name by default.");
let regex = Arg::new("regex")
.short('R')
.long("regex")
.action(ArgAction::SetTrue)
.help("Enables regex by default while searching.");
let tree = Arg::new("tree")
.short('T')
.long("tree")
.action(ArgAction::SetTrue)
.help("Makes the process widget use tree mode by default.");
let unnormalized_cpu = Arg::new("unnormalized_cpu")
.short('n')
.long("unnormalized_cpu")
.action(ArgAction::SetTrue)
.help("Show process CPU% usage without averaging over the number of CPU cores.");
let whole_word = Arg::new("whole_word")
.short('W')
.long("whole_word")
.action(ArgAction::SetTrue)
.help("Enables whole-word matching by default while searching.");
let args = args![
case_sensitive,
current_usage,
disable_advanced_kill,
group_processes,
mem_as_value,
process_command,
regex,
tree,
unnormalized_cpu,
whole_word,
];
cmd.args(args)
} }
fn temperature_args(cmd: Command) -> Command { fn temperature_args(cmd: Command) -> Command {
@ -294,7 +338,7 @@ fn temperature_args(cmd: Command) -> Command {
.short('c') .short('c')
.long("celsius") .long("celsius")
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.help("Use Celsius as the temperature unit.") .help("Use Celsius as the temperature unit. Default.")
.long_help("Use Celsius as the temperature unit. This is the default option."); .long_help("Use Celsius as the temperature unit. This is the default option.");
let fahrenheit = Arg::new("fahrenheit") let fahrenheit = Arg::new("fahrenheit")
@ -319,140 +363,35 @@ fn temperature_args(cmd: Command) -> Command {
.group(temperature_group) .group(temperature_group)
} }
fn process_args(cmd: Command) -> Command {
let cmd = cmd.next_help_heading("Process Options");
let case_sensitive = Arg::new("case_sensitive")
.short('S')
.long("case_sensitive")
.action(ArgAction::SetTrue)
.help("Enables case sensitivity by default.")
.long_help("When searching for a process, enables case sensitivity by default.");
let current_usage = Arg::new("current_usage")
.short('u')
.long("current_usage")
.action(ArgAction::SetTrue)
.help("Sets process CPU% to be based on current CPU%.")
.long_help(
"Sets process CPU% usage to be based on the current system CPU% usage rather \
than total CPU usage.",
);
let unnormalized_cpu = Arg::new("unnormalized_cpu")
.short('n')
.long("unnormalized_cpu")
.action(ArgAction::SetTrue)
.help("Show process CPU% usage without normalizing over the number of cores.")
.long_help(
"Shows all process CPU% usage without averaging over the number of CPU cores \
in the system.",
);
let group_processes = Arg::new("group_processes")
.short('g')
.long("group_processes")
.action(ArgAction::SetTrue)
.help("Groups processes with the same name by default.")
.long_help("Groups processes with the same name by default.");
let process_command = Arg::new("process_command")
.long("process_command")
.action(ArgAction::SetTrue)
.help("Show processes as their commands by default.")
.long_help("Show processes as their commands by default in the process widget.");
let regex = Arg::new("regex")
.short('R')
.long("regex")
.action(ArgAction::SetTrue)
.help("Enables regex by default.")
.long_help("When searching for a process, enables regex by default.");
let disable_advanced_kill = Arg::new("disable_advanced_kill")
.long("disable_advanced_kill")
.action(ArgAction::SetTrue)
.help("Hides advanced process killing.")
.long_help(
"Hides advanced options to stop a process on Unix-like systems. The only \
option shown is 15 (TERM).",
);
let whole_word = Arg::new("whole_word")
.short('W')
.long("whole_word")
.action(ArgAction::SetTrue)
.help("Enables whole-word matching by default.")
.long_help(
"When searching for a process, return results that match the entire query by default.",
);
let tree = Arg::new("tree")
.short('T')
.long("tree")
.action(ArgAction::SetTrue)
.help("Defaults the process widget be in tree mode.")
.long_help("Defaults to showing the process widget in tree mode.");
let args = args![
case_sensitive,
current_usage,
unnormalized_cpu,
group_processes,
process_command,
regex,
whole_word,
disable_advanced_kill,
tree,
];
cmd.args(args)
}
fn cpu_args(cmd: Command) -> Command { fn cpu_args(cmd: Command) -> Command {
let cmd = cmd.next_help_heading("CPU Options"); let cmd = cmd.next_help_heading("CPU Options");
// let default_cpu_entry = Arg::new("");
let hide_avg_cpu = Arg::new("hide_avg_cpu") let hide_avg_cpu = Arg::new("hide_avg_cpu")
.short('a') .short('a')
.long("hide_avg_cpu") .long("hide_avg_cpu")
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.help("Hides the average CPU usage.") .help("Hides the average CPU usage entry.");
.long_help("Hides the average CPU usage from being shown.");
// let default_avg_cpu = Arg::new(""); let cpu_left_legend = Arg::new("cpu_left_legend")
.long("cpu_left_legend")
.action(ArgAction::SetTrue)
.help("Puts the CPU chart legend on the left side.");
cmd.args(args![hide_avg_cpu]) cmd.args(args![hide_avg_cpu, cpu_left_legend])
} }
fn mem_args(cmd: Command) -> Command { fn mem_args(cmd: Command) -> Command {
let cmd = cmd.next_help_heading("Memory Options"); let cmd = cmd.next_help_heading("Memory Options");
let mem_as_value = Arg::new("mem_as_value")
.long("mem_as_value")
.action(ArgAction::SetTrue)
.help("Defaults to showing process memory usage by value.")
.long_help(
"Defaults to showing process memory usage by value. Otherwise, it defaults \
to showing it by percentage.",
);
let memory_legend = Arg::new("memory_legend") let memory_legend = Arg::new("memory_legend")
.long("memory_legend") .long("memory_legend")
.action(ArgAction::Set) .action(ArgAction::Set)
.value_name("POSITION") .value_name("POSITION")
.ignore_case(true) .ignore_case(true)
.help("Where to place the legend for the memory widget.") .help("Where to place the legend for the memory chart widget.")
.value_parser([ .value_parser(CHART_WIDGET_POSITIONS);
"none",
"top-left",
"top",
"top-right",
"left",
"right",
"bottom-left",
"bottom",
"bottom-right",
]);
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
{ {
@ -461,44 +400,24 @@ fn mem_args(cmd: Command) -> Command {
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.help("Enable collecting and displaying cache and buffer memory."); .help("Enable collecting and displaying cache and buffer memory.");
cmd.args(args![mem_as_value, memory_legend, enable_cache_memory]) cmd.args(args![enable_cache_memory, memory_legend])
} }
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
{ {
cmd.args(args![mem_as_value, memory_legend]) cmd.arg(memory_legend)
} }
} }
fn network_args(cmd: Command) -> Command { fn network_args(cmd: Command) -> Command {
let cmd = cmd.next_help_heading("Network Options"); let cmd = cmd.next_help_heading("Network Options");
// TODO: Change this to be configured as network graph type?
let use_old_network_legend = Arg::new("use_old_network_legend")
.long("use_old_network_legend")
.action(ArgAction::SetTrue)
.help("DEPRECATED - uses a separate network legend.")
.long_help(
"DEPRECATED - uses an older (pre-0.4), separate network widget legend. This \
display is not tested anymore and may be broken.",
);
let network_legend = Arg::new("network_legend") let network_legend = Arg::new("network_legend")
.long("network_legend") .long("network_legend")
.action(ArgAction::Set) .action(ArgAction::Set)
.value_name("POSITION") .value_name("POSITION")
.ignore_case(true) .ignore_case(true)
.help("Where to place the legend for the network widget.") .help("Where to place the legend for the network chart widget.")
.value_parser([ .value_parser(CHART_WIDGET_POSITIONS);
"none",
"top-left",
"top",
"top-right",
"left",
"right",
"bottom-left",
"bottom",
"bottom-right",
]);
let network_use_bytes = Arg::new("network_use_bytes") let network_use_bytes = Arg::new("network_use_bytes")
.long("network_use_bytes") .long("network_use_bytes")
@ -506,27 +425,34 @@ fn network_args(cmd: Command) -> Command {
.help("Displays the network widget using bytes.") .help("Displays the network widget using bytes.")
.long_help("Displays the network widget using bytes. Defaults to bits."); .long_help("Displays the network widget using bytes. Defaults to bits.");
let network_use_binary_prefix = Arg::new("network_use_binary_prefix")
.long("network_use_binary_prefix")
.action(ArgAction::SetTrue)
.help("Displays the network widget with binary prefixes.")
.long_help(
"Displays the network widget with binary prefixes (e.g. kibibits, mebibits) rather than a decimal \
prefixes (e.g. kilobits, megabits). Defaults to decimal prefixes."
);
let network_use_log = Arg::new("network_use_log") let network_use_log = Arg::new("network_use_log")
.long("network_use_log") .long("network_use_log")
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.help("Displays the network widget with a log scale.") .help("Displays the network widget with a log scale.")
.long_help("Displays the network widget with a log scale. Defaults to a non-log scale."); .long_help("Displays the network widget with a log scale. Defaults to a non-log scale.");
let network_use_binary_prefix = Arg::new("network_use_binary_prefix") // TODO: Change this to be configured as network graph type?
.long("network_use_binary_prefix") let use_old_network_legend = Arg::new("use_old_network_legend")
.long("use_old_network_legend")
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.help("Displays the network widget with binary prefixes.") .help("(DEPRECATED) Uses a separated network legend.")
.long_help( .long_help("(DEPRECATED) Uses separated network widget legend. This display is not tested and may be broken.");
"Displays the network widget with binary prefixes (i.e. kibibits, mebibits) \
rather than a decimal prefix (i.e. kilobits, megabits). Defaults to decimal prefixes.",
);
cmd.args(args![ cmd.args(args![
use_old_network_legend,
network_legend, network_legend,
network_use_bytes, network_use_bytes,
network_use_log, network_use_log,
network_use_binary_prefix, network_use_binary_prefix,
use_old_network_legend,
]) ])
} }
@ -537,9 +463,11 @@ fn battery_args(cmd: Command) -> Command {
let battery = Arg::new("battery") let battery = Arg::new("battery")
.long("battery") .long("battery")
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.help("Shows the battery widget.") .help("Shows the battery widget in non-custom layouts.")
.long_help( .long_help(
"Shows the battery widget in default or basic mode. No effect on custom layouts.", "Shows the battery widget in default or basic mode, if there is as battery available. This \
has no effect on custom layouts; if the battery widget is desired for a custom layout, explicitly \
specify it."
); );
cmd.arg(battery) cmd.arg(battery)
@ -557,6 +485,39 @@ fn gpu_args(cmd: Command) -> Command {
cmd.arg(enable_gpu) cmd.arg(enable_gpu)
} }
fn style_args(cmd: Command) -> Command {
let cmd = cmd.next_help_heading("Style Options");
// TODO: File an issue with manpage, it cannot render charts correctly.
let color = Arg::new("color")
.long("color")
.action(ArgAction::Set)
.value_name("SCHEME")
.value_parser([
"default",
"default-light",
"gruvbox",
"gruvbox-light",
"nord",
"nord-light",
])
.hide_possible_values(true)
.help(indoc! {
"Use a color scheme, use `--help` for info on the colors. [possible values: default, default-light, gruvbox, gruvbox-light, nord, nord-light]",
})
.long_help(indoc! {
"Use a pre-defined color scheme. Currently supported values are:
- default
- default-light (default but adjusted for lighter backgrounds)
- gruvbox (a bright theme with 'retro groove' colors)
- gruvbox-light (gruvbox but adjusted for lighter backgrounds)
- nord (an arctic, north-bluish color palette)
- nord-light (nord but adjusted for lighter backgrounds)"
});
cmd.arg(color)
}
fn other_args(cmd: Command) -> Command { fn other_args(cmd: Command) -> Command {
let cmd = cmd.next_help_heading("Other Options"); let cmd = cmd.next_help_heading("Other Options");
@ -564,7 +525,7 @@ fn other_args(cmd: Command) -> Command {
.short('h') .short('h')
.long("help") .long("help")
.action(ArgAction::Help) .action(ArgAction::Help)
.help("Prints help (see more info with '--help')."); .help("Prints help info (for more details use `--help`.");
let version = Arg::new("version") let version = Arg::new("version")
.short('V') .short('V')
@ -576,7 +537,16 @@ fn other_args(cmd: Command) -> Command {
} }
pub fn build_app() -> Command { pub fn build_app() -> Command {
const TEMPLATE: &str = include_str!("./args.template"); const TEMPLATE: &str = indoc! {
"{name} {version}
{author}
{about}
{usage-heading} {usage}
{all-args}"
};
const USAGE: &str = "btm [OPTIONS]"; const USAGE: &str = "btm [OPTIONS]";
const VERSION: &str = match option_env!("NIGHTLY_VERSION") { const VERSION: &str = match option_env!("NIGHTLY_VERSION") {
Some(nightly_version) => nightly_version, Some(nightly_version) => nightly_version,

View File

@ -1,8 +0,0 @@
{name} {version}
{author}
{about}
{usage-heading} {usage}
{all-args}

View File

@ -48,7 +48,7 @@ pub(crate) struct ConfigFlags {
pub(crate) dot_marker: Option<bool>, pub(crate) dot_marker: Option<bool>,
pub(crate) temperature_type: Option<String>, pub(crate) temperature_type: Option<String>,
pub(crate) rate: Option<StringOrNum>, pub(crate) rate: Option<StringOrNum>,
pub(crate) left_legend: Option<bool>, pub(crate) cpu_left_legend: Option<bool>,
pub(crate) current_usage: Option<bool>, pub(crate) current_usage: Option<bool>,
pub(crate) unnormalized_cpu: Option<bool>, pub(crate) unnormalized_cpu: Option<bool>,
pub(crate) group_processes: Option<bool>, pub(crate) group_processes: Option<bool>,
@ -62,7 +62,7 @@ pub(crate) struct ConfigFlags {
pub(crate) hide_time: Option<bool>, pub(crate) hide_time: Option<bool>,
pub(crate) default_widget_type: Option<String>, pub(crate) default_widget_type: Option<String>,
pub(crate) default_widget_count: Option<u64>, pub(crate) default_widget_count: Option<u64>,
pub(crate) expanded_on_startup: Option<bool>, pub(crate) expanded: Option<bool>,
pub(crate) use_old_network_legend: Option<bool>, pub(crate) use_old_network_legend: Option<bool>,
pub(crate) hide_table_gap: Option<bool>, pub(crate) hide_table_gap: Option<bool>,
pub(crate) battery: Option<bool>, pub(crate) battery: Option<bool>,

View File

@ -11,12 +11,12 @@ pub struct Row {
pub child: Option<Vec<RowChildren>>, pub child: Option<Vec<RowChildren>>,
} }
fn new_cpu(left_legend: bool, iter_id: &mut u64) -> BottomColRow { fn new_cpu(cpu_left_legend: bool, iter_id: &mut u64) -> BottomColRow {
let cpu_id = *iter_id; let cpu_id = *iter_id;
*iter_id += 1; *iter_id += 1;
let legend_id = *iter_id; let legend_id = *iter_id;
if left_legend { if cpu_left_legend {
BottomColRow::new(vec![ BottomColRow::new(vec![
BottomWidget::new(BottomWidgetType::CpuLegend, legend_id) BottomWidget::new(BottomWidgetType::CpuLegend, legend_id)
.canvas_with_ratio(3) .canvas_with_ratio(3)
@ -53,7 +53,7 @@ impl Row {
pub fn convert_row_to_bottom_row( pub fn convert_row_to_bottom_row(
&self, iter_id: &mut u64, total_height_ratio: &mut u32, default_widget_id: &mut u64, &self, iter_id: &mut u64, total_height_ratio: &mut u32, default_widget_id: &mut u64,
default_widget_type: &Option<BottomWidgetType>, default_widget_count: &mut u64, default_widget_type: &Option<BottomWidgetType>, default_widget_count: &mut u64,
left_legend: bool, cpu_left_legend: bool,
) -> Result<BottomRow> { ) -> Result<BottomRow> {
// TODO: In the future we want to also add percentages. // TODO: In the future we want to also add percentages.
// But for MVP, we aren't going to bother. // But for MVP, we aren't going to bother.
@ -91,7 +91,7 @@ impl Row {
children.push(match widget_type { children.push(match widget_type {
BottomWidgetType::Cpu => { BottomWidgetType::Cpu => {
BottomCol::new(vec![new_cpu(left_legend, iter_id)]) BottomCol::new(vec![new_cpu(cpu_left_legend, iter_id)])
.ratio(width_ratio) .ratio(width_ratio)
} }
BottomWidgetType::Proc => { BottomWidgetType::Proc => {
@ -153,7 +153,8 @@ impl Row {
total_col_row_ratio += col_row_height_ratio; total_col_row_ratio += col_row_height_ratio;
col_row_children.push( col_row_children.push(
new_cpu(left_legend, iter_id).ratio(col_row_height_ratio), new_cpu(cpu_left_legend, iter_id)
.ratio(col_row_height_ratio),
); );
} }
BottomWidgetType::Proc => { BottomWidgetType::Proc => {
@ -410,8 +411,8 @@ mod test {
} }
#[test] #[test]
/// Tests using left_legend. /// Tests using cpu_left_legend.
fn test_left_legend() { fn test_cpu_left_legend() {
let rows = from_str::<Config>(DEFAULT_LAYOUT).unwrap().row.unwrap(); let rows = from_str::<Config>(DEFAULT_LAYOUT).unwrap().row.unwrap();
let ret_bottom_layout = test_create_layout(&rows, DEFAULT_WIDGET_ID, None, 1, true); let ret_bottom_layout = test_create_layout(&rows, DEFAULT_WIDGET_ID, None, 1, true);
@ -478,7 +479,7 @@ mod test {
let mut default_widget_count = 1; let mut default_widget_count = 1;
let mut default_widget_id = DEFAULT_WIDGET_ID; let mut default_widget_id = DEFAULT_WIDGET_ID;
let default_widget_type = None; let default_widget_type = None;
let left_legend = false; let cpu_left_legend = false;
let mut ret_bottom_layout = BottomLayout { let mut ret_bottom_layout = BottomLayout {
rows: rows rows: rows
@ -490,7 +491,7 @@ mod test {
&mut default_widget_id, &mut default_widget_id,
&default_widget_type, &default_widget_type,
&mut default_widget_count, &mut default_widget_count,
left_legend, cpu_left_legend,
) )
}) })
.collect::<error::Result<Vec<_>>>() .collect::<error::Result<Vec<_>>>()
@ -511,7 +512,7 @@ mod test {
let mut default_widget_count = 3; let mut default_widget_count = 3;
let mut default_widget_id = DEFAULT_WIDGET_ID; let mut default_widget_id = DEFAULT_WIDGET_ID;
let default_widget_type = Some(BottomWidgetType::Proc); let default_widget_type = Some(BottomWidgetType::Proc);
let left_legend = false; let cpu_left_legend = false;
let mut ret_bottom_layout = BottomLayout { let mut ret_bottom_layout = BottomLayout {
rows: rows rows: rows
@ -523,7 +524,7 @@ mod test {
&mut default_widget_id, &mut default_widget_id,
&default_widget_type, &default_widget_type,
&mut default_widget_count, &mut default_widget_count,
left_legend, cpu_left_legend,
) )
}) })
.collect::<error::Result<Vec<_>>>() .collect::<error::Result<Vec<_>>>()