diff --git a/CHANGELOG.md b/CHANGELOG.md index 62f09a1a..9c60d394 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`. - [#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. +- [#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 diff --git a/docs/content/configuration/command-line-options.md b/docs/content/configuration/command-line-options.md index e0c6286b..9d95fc96 100644 --- a/docs/content/configuration/command-line-options.md +++ b/docs/content/configuration/command-line-options.md @@ -5,76 +5,76 @@ see information on these options by running `btm -h`, or run `btm --help` to dis ## General Options -| Option | Behaviour | -| ------------------------------------- | --------------------------------------------------- | -| `--autohide_time` | Temporarily shows the time scale in graphs. | -| `-b`, `--basic` | Hides graphs and uses a more basic look. | -| `-C`, `--config <CONFIG PATH>` | Sets the location of the config file. | -| `-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_type <WIDGET TYPE>` | Sets the default widget type, use --help for info. | -| `--disable_click` | Disables mouse clicks. | -| `-m`, `--dot_marker` | Uses a dot marker for graphs. | -| `-e`, `--expanded` | Expand the default widget upon starting the app. | -| `--hide_table_gap` | Hides spacing between table headers and entries. | -| `--hide_time` | Hides the time scale. | -| `-l`, `--left_legend` | Puts the CPU chart legend to the left side. | -| `-r`, `--rate <TIME>` | Sets the data refresh rate. | -| `--retention <TIME>` | The timespan of data stored. | -| `--show_table_scroll_position` | Shows the scroll position tracker in table widgets. | -| `-d`, `--time_delta <TIME>` | The amount of time changed upon zooming. | +| Option | Behaviour | +| --------------------------------- | ---------------------------------------------------- | +| `--autohide_time` | Temporarily shows the time scale in graphs. | +| `-b, --basic` | Hides graphs and uses a more basic look. | +| `-C, --config <CONFIG PATH>` | Sets the location of the config file. | +| `-t, --default_time_value <TIME>` | Default time value for graphs. | +| `--default_widget_count <N>` | Sets the N'th selected widget type as the default. | +| `--default_widget_type <WIDGET>` | Sets the default widget type, use `--help` for info. | +| `--disable_click` | Disables mouse clicks. | +| `-m, --dot_marker` | Uses a dot marker for graphs. | +| `-e, --expanded` | Expand the default widget upon starting the app. | +| `--hide_table_gap` | Hides spacing between table headers and entries. | +| `--hide_time` | Hides the time scale from being shown. | +| `-r, --rate <TIME>` | Sets how often data is refreshed. | +| `--retention <TIME>` | How far back data will be stored up to. | +| `--show_table_scroll_position` | Shows the scroll position tracker in table widgets. | +| `-d, --time_delta <TIME>` | The amount of time changed upon zooming. | ## Process Options -| Option | Behaviour | -| -------------------------- | --------------------------------------------------------------------- | -| `-S`, `--case_sensitive` | Enables case sensitivity by default. | -| `-u`, `--current_usage` | Sets process CPU% to be based on current CPU%. | -| `--disable_advanced_kill` | Hides advanced process killing. | -| `-g`, `--group_processes` | Groups processes with the same name by default. | -| `--process_command` | Show processes as their commands by default. | -| `-R`, `--regex` | Enables regex by default. | -| `-T`, `--tree` | Defaults the process widget be in tree mode. | -| `-n`, `--unnormalized_cpu` | Show process CPU% usage without normalizing over the number of cores. | -| `-W`, `--whole_word` | Enables whole-word matching by default. | +| Option | Behaviour | +| ------------------------- | -------------------------------------------------------------------------------------- | +| `-S, --case_sensitive` | Enables case sensitivity by default. | +| `-u, --current_usage` | Calculates process CPU usage as a percentage of current usage rather than total usage. | +| `--disable_advanced_kill` | Hides additional stopping options Unix-like systems. | +| `-g, --group_processes` | Groups processes with the same name by default. | +| `--mem_as_value` | Defaults to showing process memory usage by value. | +| `--process_command` | Shows the full command name instead of the process name by default. | +| `-R, --regex` | Enables regex by default while searching. | +| `-T, --tree` | Makes the process widget use tree mode 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 -| Option | Behaviour | -| -------------------- | --------------------------------------- | -| `-c`, `--celsius` | Use Celsius as the temperature unit. | -| `-f`, `--fahrenheit` | Use Fahrenheit as the temperature unit. | -| `-k`, `--kelvin` | Use Kelvin as the temperature unit. | +| Option | Behaviour | +| ------------------ | --------------------------------------------- | +| `-c, --celsius` | Use Celsius as the temperature unit. Default. | +| `-f, --fahrenheit` | Use Fahrenheit as the temperature unit. | +| `-k, --kelvin` | Use Kelvin as the temperature unit. | ## CPU Options -| Option | Behaviour | -| ---------------------- | ---------------------------- | -| `-a`, `--hide_avg_cpu` | Hides the average CPU usage. | +| Option | Behaviour | +| -------------------- | ------------------------------------------- | +| `--cpu_left_legend` | Puts the CPU chart legend on the left side. | +| `-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. | -| `--mem_as_value` | Defaults to showing process memory usage by value. | -| `--memory_legend` | Where to place the legend for the memory widget. | +| 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. | ## Network Options -| Option | Behaviour | -| ----------------------------- | ------------------------------------------------- | -| `--network_use_binary_prefix` | Displays the network widget with binary prefixes. | -| `--network_use_bytes` | Displays the network widget using bytes. | -| `--network_use_log` | Displays the network widget with a log scale. | -| `--network_legend` | Where to place the legend for the network widget. | -| `--use_old_network_legend` | DEPRECATED - uses a separate network legend. | +| 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_log` | Displays the network widget with a log scale. | +| `--use_old_network_legend` | (DEPRECATED) Uses a separated network legend. | ## Battery Options -| Option | Behaviour | -| ----------- | ------------------------- | -| `--battery` | Shows the battery widget. | +| Option | Behaviour | +| ----------- | ----------------------------------------------- | +| `--battery` | Shows the battery widget in non-custom layouts. | ## GPU Options @@ -84,13 +84,13 @@ see information on these options by running `btm -h`, or run `btm --help` to dis ## Style Options -| Option | Behaviour | -| ------------------------ | ---------------------------------------- | -| `--color <COLOR SCHEME>` | Use a color scheme, use --help for info. | +| Option | Behaviour | +| ------------------------ | ------------------------------------------ | +| `--color <COLOR SCHEME>` | Use a color scheme, use `--help` for info. | ## Other Options -| Option | Behaviour | -| ----------------- | ------------------------------------------ | -| `-h`, `--help` | Prints help (see more info with '--help'). | -| `-V`, `--version` | Prints version information. | +| Option | Behaviour | +| ----------------- | ------------------------------------------------- | +| `-h`, `--help` | Prints help info (for more details use `--help`.) | +| `-V`, `--version` | Prints version information. | diff --git a/docs/content/configuration/config-file/flags.md b/docs/content/configuration/config-file/flags.md index f8bacfbb..90a8d59f 100644 --- a/docs/content/configuration/config-file/flags.md +++ b/docs/content/configuration/config-file/flags.md @@ -11,7 +11,7 @@ each time: | ---------------------------- | ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------- | | `hide_avg_cpu` | Boolean | Hides the average CPU usage. | | `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%. | | `group_processes` | Boolean | Groups processes with the same name by default. | | `case_sensitive` | Boolean | Enables case sensitivity by default. | @@ -41,6 +41,6 @@ each time: | `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. | | `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. | | `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. | diff --git a/sample_configs/default_config.toml b/sample_configs/default_config.toml index 8524ea43..3c20e4f4 100644 --- a/sample_configs/default_config.toml +++ b/sample_configs/default_config.toml @@ -14,7 +14,7 @@ # The update rate of the application. #rate = "1s" # 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. #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). @@ -44,7 +44,7 @@ #default_widget_type = "proc" #default_widget_count = 1 # Expand selected widget upon starting the app -#expanded_on_startup = true +#expanded = true # Use basic mode #basic = false # Use the old network legend style diff --git a/sample_configs/demo_config.toml b/sample_configs/demo_config.toml index e6c5cf71..32dd50cd 100644 --- a/sample_configs/demo_config.toml +++ b/sample_configs/demo_config.toml @@ -5,7 +5,7 @@ avg_cpu = true temperature_type = "c" rate = 1000 -left_legend = false +cpu_left_legend = false current_usage = false group_processes = false case_sensitive = false diff --git a/schema/nightly/bottom.json b/schema/nightly/bottom.json index 1f0aeac6..b1debe2f 100644 --- a/schema/nightly/bottom.json +++ b/schema/nightly/bottom.json @@ -75,7 +75,7 @@ "description": "The update rate of the application", "type": "integer" }, - "left_legend": { + "cpu_left_legend": { "default": false, "description": "Whether to put the CPU legend to the left", "type": "boolean" @@ -141,7 +141,7 @@ "description": "Override layout default widget", "type": "integer" }, - "expanded_on_startup": { + "expanded": { "default": true, "description": "Expand selected widget upon starting the app", "type": "boolean" diff --git a/src/app.rs b/src/app.rs index 60ad35b8..11cd358b 100644 --- a/src/app.rs +++ b/src/app.rs @@ -47,7 +47,7 @@ pub struct AppConfigFields { pub update_rate: u64, pub temperature_type: temperature::TemperatureType, 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 use_current_cpu_total: 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 Some(current_widget) = self.widget_map.get(&self.current_widget.widget_id) { if let Some(cpu_widget_state) = self @@ -1872,7 +1872,7 @@ impl App { 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 Some(current_widget) = self.widget_map.get(&self.current_widget.widget_id) { if let Some(new_widget_id) = current_widget.right_neighbour { diff --git a/src/canvas/widgets/cpu_graph.rs b/src/canvas/widgets/cpu_graph.rs index f882b210..85200e98 100644 --- a/src/canvas/widgets/cpu_graph.rs +++ b/src/canvas/widgets/cpu_graph.rs @@ -30,7 +30,7 @@ impl Painter { if legend_width < 6 { // Skip drawing legend 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); } else { app_state.move_widget_selection(&WidgetDirection::Left); @@ -54,7 +54,7 @@ impl Painter { } else { let graph_width = draw_loc.width - legend_width; let (graph_index, legend_index, constraints) = - if app_state.app_config_fields.left_legend { + if app_state.app_config_fields.cpu_left_legend { ( 1, 0, diff --git a/src/constants.rs b/src/constants.rs index 1c3aa097..50e66ab7 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -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. #rate = "1s" # 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. #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). @@ -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_count = 1 # Expand selected widget upon starting the app -#expanded_on_startup = true +#expanded = true # Use basic mode #basic = false # Use the old network legend style diff --git a/src/options.rs b/src/options.rs index e36685ea..29b23178 100644 --- a/src/options.rs +++ b/src/options.rs @@ -74,7 +74,7 @@ pub fn init_app( .context("Update 'default_time_value' in your config file.")?; 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 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.")?, show_average_cpu: get_show_average_cpu(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), unnormalized_cpu: is_flag_enabled!(unnormalized_cpu, matches, config), use_basic_mode, @@ -346,7 +346,7 @@ pub fn init_app( temp_filter, net_filter, }; - let is_expanded = expanded_upon_startup && !use_basic_mode; + let is_expanded = expanded && !use_basic_mode; Ok(App::new( app_config_fields, @@ -362,7 +362,7 @@ pub fn init_app( pub fn get_widget_layout( matches: &ArgMatches, config: &Config, ) -> 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) = get_default_widget_and_count(matches, config)?; @@ -402,7 +402,7 @@ pub fn get_widget_layout( &mut default_widget_id, &default_widget_type, &mut default_widget_count, - left_legend, + cpu_left_legend, ) }) .collect::<error::Result<Vec<_>>>()?, diff --git a/src/options/args.rs b/src/options/args.rs index c8fe35320..a9d550bb 100644 --- a/src/options/args.rs +++ b/src/options/args.rs @@ -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 { let cmd = cmd.next_help_heading("General Options"); @@ -49,9 +61,8 @@ fn general_args(cmd: Command) -> Command { .action(ArgAction::SetTrue) .help("Temporarily shows the time scale in graphs.") .long_help( - "Automatically hides the time scale in graphs after being shown for \ - a brief moment when zoomed in/out. If time is disabled via --hide_time \ - then this will have no effect.", + "Automatically hides the time scale in graphs after being shown for a brief moment when zoomed \ + in/out. If time is disabled via --hide_time then this will have no effect." ); let basic = Arg::new("basic") @@ -59,47 +70,7 @@ fn general_args(cmd: Command) -> Command { .long("basic") .action(ArgAction::SetTrue) .help("Hides graphs and uses a more basic look.") - .long_help( - "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."); + .long_help("Hides graphs and uses a more basic look, largely inspired by htop's design."); let config_location = Arg::new("config_location") .short('C') @@ -108,8 +79,9 @@ fn general_args(cmd: Command) -> Command { .value_name("CONFIG PATH") .help("Sets the location of the config file.") .long_help( - "Sets the location of the config file. Expects a config file in the TOML format.\ - If it doesn't exist, one is created.", + "Sets the location of the config file. Expects a config file in the TOML format. \ + 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); @@ -120,8 +92,8 @@ fn general_args(cmd: Command) -> Command { .value_name("TIME") .help("Default time value for graphs.") .long_help( - "Default time value for graphs. Takes a number in milliseconds or a human \ - duration (e.g. 60s). The minimum time is 30s, and the default is 60s.", + "Default time value for graphs. Either a number in milliseconds or a 'human duration' \ + (e.g. 60s, 10m). Defaults to 60s, must be at least 30s.", ); // TODO: Charts are broken in the manpage @@ -129,31 +101,29 @@ fn general_args(cmd: Command) -> Command { .long("default_widget_count") .action(ArgAction::Set) .requires_all(["default_widget_type"]) - .value_name("INT") - .help("Sets the n'th selected widget type as the default.") + .value_name("N") + .help("Sets the N'th selected widget type as the default.") .long_help(indoc! { - "Sets the n'th selected widget type to use as the default widget. - Requires 'default_widget_type' to also be set, and defaults to 1. + "Sets the N'th selected widget type to use as the default widget. Requires 'default_widget_type' to also be \ + set, and defaults to 1. - This reads from left to right, top to bottom. For example, suppose - we have a layout that looks like: + This reads from left to right, top to bottom. For example, suppose we have a layout that looks like: +-------------------+-----------------------+ | CPU (1) | CPU (2) | +---------+---------+-------------+---------+ | Process | CPU (3) | Temperature | CPU (4) | +---------+---------+-------------+---------+ - And we set our default widget type to 'CPU'. If we set - '--default_widget_count 1', then it would use the CPU (1) as - the default widget. If we set '--default_widget_count 3', it would - use CPU (3) as the default instead." + And we set our default widget type to 'CPU'. If we set '--default_widget_count 1', then it would use the \ + CPU (1) as the default widget. If we set '--default_widget_count 3', it would use CPU (3) as the default \ + instead." }); let default_widget_type = Arg::new("default_widget_type") .long("default_widget_type") .action(ArgAction::Set) - .value_name("WIDGET TYPE") - .help("Sets the default widget type, use --help for info.") + .value_name("WIDGET") + .help("Sets the default widget type, use `--help` for info.") .long_help(indoc!{ "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 \ @@ -166,7 +136,7 @@ fn general_args(cmd: Command) -> Command { | 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([ "cpu", @@ -179,36 +149,73 @@ fn general_args(cmd: Command) -> Command { "temp", "temperature", "disk", - #[cfg(not(feature = "battery"))] + #[cfg(feature = "battery")] "batt", - #[cfg(not(feature = "battery"))] + #[cfg(feature = "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') .long("expanded") .action(ArgAction::SetTrue) .help("Expand the default widget upon starting the app.") - .long_help( - "Expand the default widget upon starting the app. \ - Same as pressing \"e\" inside the app. Use with \"default_widget_type\" \ - and \"default_widget_count\" to select the desired expanded widget. This \ - flag has no effect in basic mode (--basic).", - ); + .long_help("Expand the default widget upon starting the app. This flag has no effect in basic mode (--basic)."); + + let hide_table_gap = Arg::new("hide_table_gap") + .long("hide_table_gap") + .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") .short('r') .long("rate") .action(ArgAction::Set) .value_name("TIME") - .help("Sets the data refresh rate.") + .help("Sets how often data is refreshed.") .long_help( - "Sets the data refresh rate. Takes a number in milliseconds or a human\ - duration (e.g. 5s). The minimum is 250ms, and defaults to 1000ms. Smaller \ - values may take more computer resources.", + "Sets how often data is refreshed. Either a number in milliseconds or a 'human duration' \ + (e.g. 1s, 1m). Defaults to 1s, must be at least 250ms. Smaller values may result in \ + 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") .short('d') .long("time_delta") @@ -221,70 +228,107 @@ fn general_args(cmd: Command) -> Command { 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![ autohide_time, basic, + config_location, + default_widget_count, + default_time_value, + default_widget_type, disable_click, dot_marker, + expanded, hide_table_gap, hide_time, - left_legend, - show_table_scroll_position, - config_location, - default_time_value, - default_widget_count, - default_widget_type, - expanded_on_startup, rate, - time_delta, retention, + show_table_scroll_position, + time_delta, ]) } -fn style_args(cmd: Command) -> Command { - let cmd = cmd.next_help_heading("Style Options"); +fn process_args(cmd: Command) -> Command { + let cmd = cmd.next_help_heading("Process Options"); - // TODO: File an issue with manpage, it cannot render charts correctly. - let color = Arg::new("color") - .long("color") - .action(ArgAction::Set) - .value_name("COLOR SCHEME") - .value_parser([ - "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)" - }); + let case_sensitive = Arg::new("case_sensitive") + .short('S') + .long("case_sensitive") + .action(ArgAction::SetTrue) + .help("Enables case sensitivity by default.") + .long_help("Enables case sensitivity by default when searching for a process."); - 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 { @@ -294,7 +338,7 @@ fn temperature_args(cmd: Command) -> Command { .short('c') .long("celsius") .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."); let fahrenheit = Arg::new("fahrenheit") @@ -319,140 +363,35 @@ fn temperature_args(cmd: Command) -> Command { .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 { let cmd = cmd.next_help_heading("CPU Options"); + // let default_cpu_entry = Arg::new(""); + let hide_avg_cpu = Arg::new("hide_avg_cpu") .short('a') .long("hide_avg_cpu") .action(ArgAction::SetTrue) - .help("Hides the average CPU usage.") - .long_help("Hides the average CPU usage from being shown."); + .help("Hides the average CPU usage entry."); - // 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 { 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") .long("memory_legend") .action(ArgAction::Set) .value_name("POSITION") .ignore_case(true) - .help("Where to place the legend for the memory widget.") - .value_parser([ - "none", - "top-left", - "top", - "top-right", - "left", - "right", - "bottom-left", - "bottom", - "bottom-right", - ]); + .help("Where to place the legend for the memory chart widget.") + .value_parser(CHART_WIDGET_POSITIONS); #[cfg(not(target_os = "windows"))] { @@ -461,44 +400,24 @@ fn mem_args(cmd: Command) -> Command { .action(ArgAction::SetTrue) .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")] { - cmd.args(args![mem_as_value, memory_legend]) + cmd.arg(memory_legend) } } fn network_args(cmd: Command) -> Command { 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") .long("network_legend") .action(ArgAction::Set) .value_name("POSITION") .ignore_case(true) - .help("Where to place the legend for the network widget.") - .value_parser([ - "none", - "top-left", - "top", - "top-right", - "left", - "right", - "bottom-left", - "bottom", - "bottom-right", - ]); + .help("Where to place the legend for the network chart widget.") + .value_parser(CHART_WIDGET_POSITIONS); let network_use_bytes = Arg::new("network_use_bytes") .long("network_use_bytes") @@ -506,27 +425,34 @@ fn network_args(cmd: Command) -> Command { .help("Displays the network widget using bytes.") .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") .long("network_use_log") .action(ArgAction::SetTrue) .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."); - let network_use_binary_prefix = Arg::new("network_use_binary_prefix") - .long("network_use_binary_prefix") + // 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("Displays the network widget with binary prefixes.") - .long_help( - "Displays the network widget with binary prefixes (i.e. kibibits, mebibits) \ - rather than a decimal prefix (i.e. kilobits, megabits). Defaults to decimal prefixes.", - ); + .help("(DEPRECATED) Uses a separated network legend.") + .long_help("(DEPRECATED) Uses separated network widget legend. This display is not tested and may be broken."); cmd.args(args![ - use_old_network_legend, network_legend, network_use_bytes, network_use_log, network_use_binary_prefix, + use_old_network_legend, ]) } @@ -537,9 +463,11 @@ fn battery_args(cmd: Command) -> Command { let battery = Arg::new("battery") .long("battery") .action(ArgAction::SetTrue) - .help("Shows the battery widget.") + .help("Shows the battery widget in non-custom layouts.") .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) @@ -557,6 +485,39 @@ fn gpu_args(cmd: Command) -> Command { 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 { let cmd = cmd.next_help_heading("Other Options"); @@ -564,7 +525,7 @@ fn other_args(cmd: Command) -> Command { .short('h') .long("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") .short('V') @@ -576,7 +537,16 @@ fn other_args(cmd: Command) -> 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 VERSION: &str = match option_env!("NIGHTLY_VERSION") { Some(nightly_version) => nightly_version, diff --git a/src/options/args.template b/src/options/args.template deleted file mode 100644 index c4712b35..00000000 --- a/src/options/args.template +++ /dev/null @@ -1,8 +0,0 @@ -{name} {version} -{author} - -{about} - -{usage-heading} {usage} - -{all-args} \ No newline at end of file diff --git a/src/options/config.rs b/src/options/config.rs index 6b3643f0..8a150ee8 100644 --- a/src/options/config.rs +++ b/src/options/config.rs @@ -48,7 +48,7 @@ pub(crate) struct ConfigFlags { pub(crate) dot_marker: Option<bool>, pub(crate) temperature_type: Option<String>, 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) unnormalized_cpu: Option<bool>, pub(crate) group_processes: Option<bool>, @@ -62,7 +62,7 @@ pub(crate) struct ConfigFlags { pub(crate) hide_time: Option<bool>, pub(crate) default_widget_type: Option<String>, 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) hide_table_gap: Option<bool>, pub(crate) battery: Option<bool>, diff --git a/src/options/config/layout.rs b/src/options/config/layout.rs index 90467e11..04105bd8 100644 --- a/src/options/config/layout.rs +++ b/src/options/config/layout.rs @@ -11,12 +11,12 @@ pub struct Row { 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; *iter_id += 1; let legend_id = *iter_id; - if left_legend { + if cpu_left_legend { BottomColRow::new(vec![ BottomWidget::new(BottomWidgetType::CpuLegend, legend_id) .canvas_with_ratio(3) @@ -53,7 +53,7 @@ impl Row { pub fn convert_row_to_bottom_row( &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, - left_legend: bool, + cpu_left_legend: bool, ) -> Result<BottomRow> { // TODO: In the future we want to also add percentages. // But for MVP, we aren't going to bother. @@ -91,7 +91,7 @@ impl Row { children.push(match widget_type { BottomWidgetType::Cpu => { - BottomCol::new(vec![new_cpu(left_legend, iter_id)]) + BottomCol::new(vec![new_cpu(cpu_left_legend, iter_id)]) .ratio(width_ratio) } BottomWidgetType::Proc => { @@ -153,7 +153,8 @@ impl Row { total_col_row_ratio += col_row_height_ratio; 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 => { @@ -410,8 +411,8 @@ mod test { } #[test] - /// Tests using left_legend. - fn test_left_legend() { + /// Tests using cpu_left_legend. + fn test_cpu_left_legend() { let rows = from_str::<Config>(DEFAULT_LAYOUT).unwrap().row.unwrap(); 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_id = DEFAULT_WIDGET_ID; let default_widget_type = None; - let left_legend = false; + let cpu_left_legend = false; let mut ret_bottom_layout = BottomLayout { rows: rows @@ -490,7 +491,7 @@ mod test { &mut default_widget_id, &default_widget_type, &mut default_widget_count, - left_legend, + cpu_left_legend, ) }) .collect::<error::Result<Vec<_>>>() @@ -511,7 +512,7 @@ mod test { let mut default_widget_count = 3; let mut default_widget_id = DEFAULT_WIDGET_ID; let default_widget_type = Some(BottomWidgetType::Proc); - let left_legend = false; + let cpu_left_legend = false; let mut ret_bottom_layout = BottomLayout { rows: rows @@ -523,7 +524,7 @@ mod test { &mut default_widget_id, &default_widget_type, &mut default_widget_count, - left_legend, + cpu_left_legend, ) }) .collect::<error::Result<Vec<_>>>()