diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2024-04-11 00:46:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-10 20:46:35 -0400 |
commit | 93d67187664fc43814955fbf94511bbfb2cf6eca (patch) | |
tree | 7a1a38d228025ef50b2770cd65866074725c2e0b /src | |
parent | bb0bc8a0b0efb92d6e99ec46ca08d7b2d9652e57 (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/app.rs | 6 | ||||
-rw-r--r-- | src/canvas/widgets/cpu_graph.rs | 4 | ||||
-rw-r--r-- | src/constants.rs | 4 | ||||
-rw-r--r-- | src/options.rs | 10 | ||||
-rw-r--r-- | src/options/args.rs | 490 | ||||
-rw-r--r-- | src/options/args.template | 8 | ||||
-rw-r--r-- | src/options/config.rs | 4 | ||||
-rw-r--r-- | src/options/config/layout.rs | 23 |
8 files changed, 256 insertions, 293 deletions
@@ -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,104 +228,25 @@ 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"); - - // 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)" - }); - - cmd.arg(color) -} - -fn temperature_args(cmd: Command) -> Command { - let cmd = cmd.next_help_heading("Temperature Options"); - - let celsius = Arg::new("celsius") - .short('c') - .long("celsius") - .action(ArgAction::SetTrue) - .help("Use Celsius as the temperature unit.") - .long_help("Use Celsius as the temperature unit. This is the default option."); - - let fahrenheit = Arg::new("fahrenheit") - .short('f') - .long("fahrenheit") - .action(ArgAction::SetTrue) - .help("Use Fahrenheit as the temperature unit."); - - let kelvin = Arg::new("kelvin") - .short('k') - .long("kelvin") - .action(ArgAction::SetTrue) - .help("Use Kelvin as the temperature unit."); - - let temperature_group = ArgGroup::new("TEMPERATURE_TYPE").args([ - celsius.get_id(), - fahrenheit.get_id(), - kelvin.get_id(), - ]); - - cmd.args(args![celsius, fahrenheit, kelvin]) - .group(temperature_group) -} - fn process_args(cmd: Command) -> Command { let cmd = cmd.next_help_heading("Process Options"); @@ -327,132 +255,143 @@ fn process_args(cmd: Command) -> Command { .long("case_sensitive") .action(ArgAction::SetTrue) .help("Enables case sensitivity by default.") - .long_help("When searching for a process, enables case sensitivity by default."); + .long_help("Enables case sensitivity by default when searching for a process."); + // TODO: Rename this. 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.", - ); + .help("Calculates process CPU usage as a percentage of current usage rather than total usage."); - let unnormalized_cpu = Arg::new("unnormalized_cpu") - .short('n') - .long("unnormalized_cpu") + // TODO: Disable this on Windows? + let disable_advanced_kill = Arg::new("disable_advanced_kill") + .long("disable_advanced_kill") .action(ArgAction::SetTrue) - .help("Show process CPU% usage without normalizing over the number of cores.") + .help("Hides additional stopping options Unix-like systems.") .long_help( - "Shows all process CPU% usage without averaging over the number of CPU cores \ - in the system.", + "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.") - .long_help("Groups processes with the same name by default."); + .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("Show processes as their commands by default.") - .long_help("Show processes as their commands by default in the process widget."); + .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.") - .long_help("When searching for a process, enables regex by default."); + .help("Enables regex by default while searching."); - let disable_advanced_kill = Arg::new("disable_advanced_kill") - .long("disable_advanced_kill") + let tree = Arg::new("tree") + .short('T') + .long("tree") .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).", - ); + .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.") - .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."); + .help("Enables whole-word matching by default while searching."); let args = args![ case_sensitive, current_usage, - unnormalized_cpu, + disable_advanced_kill, group_processes, + mem_as_value, process_command, regex, - whole_word, - disable_advanced_kill, tree, + unnormalized_cpu, + whole_word, ]; cmd.args(args) } +fn temperature_args(cmd: Command) -> Command { + let cmd = cmd.next_help_heading("Temperature Options"); + + let celsius = Arg::new("celsius") + .short('c') + .long("celsius") + .action(ArgAction::SetTrue) + .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") + .short('f') + .long("fahrenheit") + .action(ArgAction::SetTrue) + .help("Use Fahrenheit as the temperature unit."); + + let kelvin = Arg::new("kelvin") + .short('k') + .long("kelvin") + .action(ArgAction::SetTrue) + .help("Use Kelvin as the temperature unit."); + + let temperature_group = ArgGroup::new("TEMPERATURE_TYPE").args([ + celsius.get_id(), + fahrenheit.get_id(), + kelvin.get_id(), + ]); + + cmd.args(args![celsius, fahrenheit, kelvin]) + .group(temperature_group) +} + 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 6b3643 |