From 5aa7b4df082bce4d029757c911893a93347d0d61 Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Mon, 31 Aug 2020 18:57:01 -0400 Subject: [PATCH] docs: Update some arguments, and documentation (#214) Some more updates to arguments and documentation. --- .vscode/settings.json | 1 + CHANGELOG.md | 2 ++ README.md | 60 +++++++++++++++------------------- src/clap.rs | 76 ++++++++++++++++++++++++++++++++++--------- 4 files changed, 90 insertions(+), 49 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3c0c2b46..d3f49cfa 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -37,6 +37,7 @@ "crossterm", "curr", "czvf", + "fpath", "gotop", "gtop", "haase", diff --git a/CHANGELOG.md b/CHANGELOG.md index fa1f2b1e..57dfe3ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changes +- [#213](https://github.com/ClementTsang/bottom/pull/213), [#214](https://github.com/ClementTsang/bottom/pull/214): Updated help descriptions, added auto-complete generation. + ### Bug Fixes - [#211](https://github.com/ClementTsang/bottom/pull/211): Fixes a bug where you could move down in the process widget even if the process widget search was closed. diff --git a/README.md b/README.md index 16f39576..0083f3f7 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@ A cross-platform graphical process/system monitor with a customizable interface - [Auto-completion](#auto-completion) - [Usage](#usage) - [Flags](#flags) - - [Options](#options) - [Keybindings](#keybindings) - [General](#general) - [Process bindings](#process-bindings) @@ -176,37 +175,32 @@ Run using `btm`. ### Flags ``` --h, --help Prints help information, including flags and options --a, --hide_avg_cpu Hides the average CPU usage --m, --dot-marker Uses a dot marker instead of the default braille marker --c, --celsius Displays the temperature type in Celsius [default] --f, --fahrenheit Displays the temperature type in Fahrenheit --k, --kelvin Displays the temperature type in Kelvin --l, --left_legend Displays the CPU legend to the left rather than the right --u, --current_usage Sets process CPU usage to be based on current total CPU usage --g, --group Groups together processes with the same name by default --S, --case_sensitive Search defaults to matching cases --W, --whole Search defaults to searching for the whole word --R, --regex Search defaults to using regex --s, --show_disabled_data Shows disabled CPU entries in the CPU legend --b, --basic Enables basic mode, removing charts and condensing data - --autohide_time Automatically hide the time scaling 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 - --use_old_network_legend Use the older (pre-0.4) network legend which is separate from the network chart - --hide_table_gap Hides the spacing between table headers and data - --battery Displays the battery widget for default and basic layouts - --disable_click Disables mouse clicks from interacting with the program -``` - -### Options - -``` --r, --rate Set the refresh rate in milliseconds [default: 1000] --C, --config Use the specified config file; if it does not exist it is automatically created [default: see section on config files] --t, --default_time_value Sets the default time interval for charts in milliseconds [default: 60000] --d, --time_delta Sets the default amount each zoom in/out action changes by in milliseconds [default: 15000] - --default_widget_count Which number of the selected widget type to select, from left to right, top to bottom [default: 1] - --default_widget_type The default widget type to select by default [default: "process"] + --autohide_time Temporarily shows the time scale in graphs. + -b, --basic Hides graphs and uses a more basic look. + --battery Shows the battery widget. + -S, --case_sensitive Enables case sensitivity by default. + -c, --celsius Sets the temperature type to Celsius. + -C, --config Sets the location of the config file. + -t, --default_time_value Default time value for graphs in ms. + --default_widget_count Sets the n'th selected widget type as the default. + --default_widget_type Sets which widget type to use as the default widget. + --disable_click Disables mouse clicks. + -m, --dot_marker Uses a dot marker for graphs. + -f, --fahrenheit Sets the temperature type to Fahrenheit. + -g, --group Groups processes with the same name by default. + -a, --hide_avg_cpu Hides the average CPU usage. + --hide_table_gap Hides the spacing between table headers and entries. + --hide_time Completely hides the time scaling. + -k, --kelvin Sets the temperature type to Kelvin. + -l, --left_legend Puts the CPU chart legend to the left side. + -r, --rate Sets a refresh rate in ms. + -R, --regex Enables regex by default. + -d, --time_delta The amount in ms changed upon zooming. + -u, --current_usage Sets process CPU% to be based on current CPU%. + --use_old_network_legend DEPRECATED - uses the older network legend. + -W, --whole_word Enables whole-word matching by default. + -h, --help Prints help information. Use --help for more info. + -V, --version Prints version information. ``` ### Keybindings @@ -466,7 +460,7 @@ Note that if a config file does not exist at either the default location or the The following options can be set under `[flags]` to achieve the same effect as passing in a flag on runtime. Note that if a flag is given, it will override the config file. -These are the following supported flag config values, which correspond to the flag of the same name described in [Flags](#flags) and [Options](#options): +These are the following supported flag config values, which correspond to the flag of the same name described in [Flags](#flags): | Field | Type | | ------------------------ | ------------------------------------------------------------------------------------- | diff --git a/src/clap.rs b/src/clap.rs index eb376d8b..e4bed377 100644 --- a/src/clap.rs +++ b/src/clap.rs @@ -6,15 +6,13 @@ const TEMPLATE: &str = "\ {about} -USAGE: -{usage} +USAGE:{usage} FLAGS: -{flags} +{unified}"; -OPTIONS: -{options} -"; +const USAGE: &str = " + btm [FLAG]"; pub fn get_matches() -> clap::ArgMatches<'static> { build_app().get_matches() @@ -198,13 +196,28 @@ time is 30s (30000), and the default is 60s (60000).\n\n\n", let default_widget_count = Arg::with_name("DEFAULT_WIDGET_COUNT") .long("default_widget_count") .takes_value(true) + .requires_all(&["DEFAULT_WIDGET_TYPE"]) .value_name("INT") .help("Sets the n'th selected widget type as the default.") .long_help( "\ Sets the n'th selected widget type to use as the default widget. -Goes from left to right, top to bottom.\n\n", - ); //FIXME: Explain this +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: ++-------------------+-----------------------+ +| 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. +\n\n", + ); let default_widget_type = Arg::with_name("DEFAULT_WIDGET_TYPE") .long("default_widget_type") .takes_value(true) @@ -213,8 +226,37 @@ Goes from left to right, top to bottom.\n\n", .long_help( "\ Sets which widget type to use as the default widget. -Acceptable widget types are...\n\n", - ); //FIXME: Expand +For the default layout, this defaults to the 'process' widget. +For a custom layout, it defaults to the first widget it sees. + +For example, suppose we have a layout that looks like: ++-------------------+-----------------------+ +| CPU (1) | CPU (2) | ++---------+---------+-------------+---------+ +| Process | CPU (3) | Temperature | CPU (4) | ++---------+---------+-------------+---------+ + +Setting '--default_widget_type Temp' will make the Temperature +widget selected by default. + +Supported widget types: ++--------------------------+ +| cpu | ++--------------------------+ +| mem, memory | ++--------------------------+ +| net, network | ++--------------------------+ +| proc, process, processes | ++--------------------------+ +| temp, temperature | ++--------------------------+ +| disk | ++--------------------------+ +| batt, battery | ++--------------------------+ +\n\n", + ); let rate = Arg::with_name("RATE_MILLIS") .short("r") .long("rate") @@ -239,10 +281,12 @@ The minimum is 1s (1000), and defaults to 15s (15000).\n\n\n", ); App::new(crate_name!()) + .setting(AppSettings::UnifiedHelpMessage) .version(crate_version!()) .author(crate_authors!()) .about(crate_description!()) .template(TEMPLATE) + .usage(USAGE) .help_message("Prints help information. Use --help for more info.") .version_message("Prints version information.") .arg(kelvin) @@ -253,6 +297,10 @@ The minimum is 1s (1000), and defaults to 15s (15000).\n\n\n", .arg(basic) .arg(battery) .arg(case_sensitive) + .arg(config) + .arg(default_time_value) + .arg(default_widget_count) + .arg(default_widget_type) .arg(disable_click) .arg(dot_marker) .arg(group) @@ -260,14 +308,10 @@ The minimum is 1s (1000), and defaults to 15s (15000).\n\n\n", .arg(hide_table_gap) .arg(hide_time) .arg(left_legend) + .arg(rate) .arg(regex) + .arg(time_delta) .arg(current_usage) .arg(use_old_network_legend) .arg(whole_word) - .arg(config) - .arg(default_time_value) - .arg(default_widget_count) - .arg(default_widget_type) - .arg(rate) - .arg(time_delta) }