refactor: clean up arg code more (#1377)
* fix sort function * Try macros * Revert "Try macros" This reverts commit93c7306f8a
. * use next_help_heading instead * test * Revert "test" This reverts commit017a1702b3
. * Reapply "test" This reverts commit23c09d3828
. * use foldl instead :) * a word * different conditionals * update docs, change ordering * more formatting stuff
This commit is contained in:
parent
6b62176554
commit
bc2c363a49
|
@ -78,7 +78,7 @@ As (yet another) process/system visualization and management application, bottom
|
||||||
|
|
||||||
- [Cross-platform support](https://github.com/ClementTsang/bottom#support) for Linux, macOS, and Windows, with more planned in the future.
|
- [Cross-platform support](https://github.com/ClementTsang/bottom#support) for Linux, macOS, and Windows, with more planned in the future.
|
||||||
|
|
||||||
- [Customizable behaviour](https://clementtsang.github.io/bottom/nightly/configuration/command-line-flags/) that can be controlled with command-line flags or a config file, such as:
|
- [Customizable behaviour](https://clementtsang.github.io/bottom/nightly/configuration/command-line-options/) that can be controlled with command-line flags or a config file, such as:
|
||||||
|
|
||||||
- Custom and built-in colour themes
|
- Custom and built-in colour themes
|
||||||
- Customizing widget behaviour
|
- Customizing widget behaviour
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
# Command-line Flags
|
|
||||||
|
|
||||||
The following flags can be provided to bottom in the command line to change the behaviour of the program. You can also
|
|
||||||
see information on these flags by running `btm -h`, or run `btm --help` to display more detailed information on each flag:
|
|
||||||
|
|
||||||
| Flag | Behaviour |
|
|
||||||
| ----------------------------------- | --------------------------------------------------------------------- |
|
|
||||||
| --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. |
|
|
||||||
| --color <COLOR SCHEME> | Use a color scheme, use --help for info. |
|
|
||||||
| -C, --config <CONFIG PATH> | Sets the location of the config file. |
|
|
||||||
| -u, --current_usage | Sets process CPU% to be based on current CPU%. |
|
|
||||||
| -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_advanced_kill | Hides advanced process killing. |
|
|
||||||
| --disable_click | Disables mouse clicks. |
|
|
||||||
| -m, --dot_marker | Uses a dot marker for graphs. |
|
|
||||||
| --enable_cache_memory | Enable collecting and displaying cache and buffer memory. |
|
|
||||||
| --enable_gpu | Enable collecting and displaying GPU usage. |
|
|
||||||
| -e, --expanded | Expand the default widget upon starting the app. |
|
|
||||||
| -f, --fahrenheit | Sets the temperature type to Fahrenheit. |
|
|
||||||
| -g, --group_processes | Groups processes with the same name by default. |
|
|
||||||
| -a, --hide_avg_cpu | Hides the average CPU usage. |
|
|
||||||
| --hide_table_gap | Hides spacing between table headers and entries. |
|
|
||||||
| --hide_time | Hides the time scale. |
|
|
||||||
| -k, --kelvin | Sets the temperature type to Kelvin. |
|
|
||||||
| -l, --left_legend | Puts the CPU chart legend to the left side. |
|
|
||||||
| --mem_as_value | Defaults to showing process memory usage by value. |
|
|
||||||
| --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. |
|
|
||||||
| --process_command | Show processes as their commands by default. |
|
|
||||||
| -r, --rate <TIME> | Sets the data refresh rate. |
|
|
||||||
| -R, --regex | Enables regex by default. |
|
|
||||||
| --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. |
|
|
||||||
| -T, --tree | Defaults the process widget be in tree mode. |
|
|
||||||
| -n, --unnormalized_cpu | Show process CPU% usage without normalizing over the number of cores. |
|
|
||||||
| --use_old_network_legend | DEPRECATED - uses a separate network legend. |
|
|
||||||
| -V, --version | Prints version information. |
|
|
||||||
| -W, --whole_word | Enables whole-word matching by default. |
|
|
||||||
| -h, --help | Print help (see more with '--help') |
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
# Command-line Options
|
||||||
|
|
||||||
|
The following options can be provided to bottom in the command line to change the behaviour of the program. You can also
|
||||||
|
see information on these options by running `btm -h`, or run `btm --help` to display more detailed information on each option:
|
||||||
|
|
||||||
|
## 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. |
|
||||||
|
|
||||||
|
## 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. |
|
||||||
|
|
||||||
|
## 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. |
|
||||||
|
|
||||||
|
## CPU Options
|
||||||
|
|
||||||
|
| Option | Behaviour |
|
||||||
|
| ------------------ | ---------------------------- |
|
||||||
|
| -a, --hide_avg_cpu | Hides the average CPU usage. |
|
||||||
|
|
||||||
|
## 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. |
|
||||||
|
|
||||||
|
## 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. |
|
||||||
|
| --use_old_network_legend | DEPRECATED - uses a separate network legend. |
|
||||||
|
|
||||||
|
## Battery Options
|
||||||
|
|
||||||
|
| Option | Behaviour |
|
||||||
|
| --------- | ------------------------- |
|
||||||
|
| --battery | Shows the battery widget. |
|
||||||
|
|
||||||
|
## GPU Options
|
||||||
|
|
||||||
|
| Option | Behaviour |
|
||||||
|
| ------------ | ------------------------------------------- |
|
||||||
|
| --enable_gpu | Enable collecting and displaying GPU usage. |
|
||||||
|
|
||||||
|
## Style Options
|
||||||
|
|
||||||
|
| 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. |
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
This section is in progress, and is just copied from the old documentation.
|
This section is in progress, and is just copied from the old documentation.
|
||||||
|
|
||||||
Most of the [command line flags](../command-line-flags.md) have config file equivalents to avoid having to type them out
|
Most of the [command line flags](../command-line-options.md) have config file equivalents to avoid having to type them out
|
||||||
each time:
|
each time:
|
||||||
|
|
||||||
| Field | Type | Functionality |
|
| Field | Type | Functionality |
|
||||||
|
|
|
@ -31,7 +31,7 @@ which contains a list of all the installation methods.
|
||||||
|
|
||||||
You can refer to the [usage](usage/general-usage.md) pages on how to use bottom (e.g. keybinds, some features, a general overview of what each widget does).
|
You can refer to the [usage](usage/general-usage.md) pages on how to use bottom (e.g. keybinds, some features, a general overview of what each widget does).
|
||||||
|
|
||||||
To configure bottom, refer to the [configuration](configuration/command-line-flags.md) pages (e.g. how it behaves, how it looks).
|
To configure bottom, refer to the [configuration](configuration/command-line-options.md) pages (e.g. how it behaves, how it looks).
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ received and transmitted.
|
||||||
The legend displays the current reads and writes per second in bits, as well as the total amount read/written.
|
The legend displays the current reads and writes per second in bits, as well as the total amount read/written.
|
||||||
|
|
||||||
The y-axis automatically scales based on shown read/write values, and by default, is a linear scale based on base-10 units (e.x. kilobit, gigabit, etc.).
|
The y-axis automatically scales based on shown read/write values, and by default, is a linear scale based on base-10 units (e.x. kilobit, gigabit, etc.).
|
||||||
Through [configuration](../../configuration/command-line-flags.md), the read/write per second unit can be changed to bytes, while the y-axis can be changed to a
|
Through [configuration](../../configuration/command-line-options.md), the read/write per second unit can be changed to bytes, while the y-axis can be changed to a
|
||||||
log scale and/or use base-2 units (e.x. kibibit, gibibit, etc.).
|
log scale and/or use base-2 units (e.x. kibibit, gibibit, etc.).
|
||||||
|
|
||||||
One can also adjust the displayed time range through either the keyboard or mouse, with a range of 30s to 600s.
|
One can also adjust the displayed time range through either the keyboard or mouse, with a range of 30s to 600s.
|
||||||
|
|
|
@ -140,7 +140,7 @@ nav:
|
||||||
- "Temperature Widget": usage/widgets/temperature.md
|
- "Temperature Widget": usage/widgets/temperature.md
|
||||||
- "Battery Widget": usage/widgets/battery.md
|
- "Battery Widget": usage/widgets/battery.md
|
||||||
- "Configuration":
|
- "Configuration":
|
||||||
- "Command-line Flags": configuration/command-line-flags.md
|
- "Command-line Flags": configuration/command-line-options.md
|
||||||
- "Config File":
|
- "Config File":
|
||||||
- "Default Config": configuration/config-file/default-config.md
|
- "Default Config": configuration/config-file/default-config.md
|
||||||
- "Flags": configuration/config-file/flags.md
|
- "Flags": configuration/config-file/flags.md
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
//! Note that you probably want to keep this as a single file so the build script doesn't
|
//! Note that you probably want to keep this as a single file so the build script doesn't
|
||||||
//! trip all over itself.
|
//! trip all over itself.
|
||||||
|
|
||||||
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
use clap::{builder::PossibleValuesParser, *};
|
use clap::{builder::PossibleValuesParser, *};
|
||||||
|
|
||||||
const DEFAULT_WIDGET_TYPE_STR: &str = {
|
const DEFAULT_WIDGET_TYPE_STR: &str = {
|
||||||
|
@ -80,31 +82,35 @@ pub fn get_matches() -> ArgMatches {
|
||||||
build_app().get_matches()
|
build_app().get_matches()
|
||||||
}
|
}
|
||||||
|
|
||||||
trait CommandBuilder {
|
/// Returns an [`Ordering`] for two [`Arg`] values.
|
||||||
fn general_args(self) -> Self;
|
///
|
||||||
|
/// Note this assumes that they both have a _long_ name, and will
|
||||||
|
/// panic if either are missing!
|
||||||
|
fn sort_args(a: &Arg, b: &Arg) -> Ordering {
|
||||||
|
let a = a.get_long().unwrap();
|
||||||
|
let b = b.get_long().unwrap();
|
||||||
|
|
||||||
fn style_args(self) -> Self;
|
a.cmp(b)
|
||||||
|
|
||||||
fn temperature_args(self) -> Self;
|
|
||||||
|
|
||||||
fn process_args(self) -> Self;
|
|
||||||
|
|
||||||
fn cpu_args(self) -> Self;
|
|
||||||
|
|
||||||
fn mem_args(self) -> Self;
|
|
||||||
|
|
||||||
fn network_args(self) -> Self;
|
|
||||||
|
|
||||||
fn battery_args(self) -> Self;
|
|
||||||
|
|
||||||
fn gpu_args(self) -> Self;
|
|
||||||
|
|
||||||
fn other(self) -> Self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CommandBuilder for Command {
|
/// Create an array of [`Arg`] values. If there is more than one value, then
|
||||||
fn general_args(self) -> Command {
|
/// they will be sorted by their long name. Note this sort will panic if
|
||||||
const HEADING: &str = "General Options";
|
/// any [`Arg`] does not have a long name!
|
||||||
|
macro_rules! args {
|
||||||
|
( $arg:expr $(,)?) => {
|
||||||
|
[$arg]
|
||||||
|
};
|
||||||
|
( $( $arg:expr ),+ $(,)? ) => {
|
||||||
|
{
|
||||||
|
let mut args = [ $( $arg, )* ];
|
||||||
|
args.sort_unstable_by(sort_args);
|
||||||
|
args
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn general_args(cmd: Command) -> Command {
|
||||||
|
let cmd = cmd.next_help_heading("General Options");
|
||||||
|
|
||||||
let autohide_time = Arg::new("autohide_time")
|
let autohide_time = Arg::new("autohide_time")
|
||||||
.long("autohide_time")
|
.long("autohide_time")
|
||||||
|
@ -114,8 +120,7 @@ impl CommandBuilder for Command {
|
||||||
"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 in/out. If time is disabled via --hide_time \
|
a brief moment when zoomed in/out. If time is disabled via --hide_time \
|
||||||
then this will have no effect.",
|
then this will have no effect.",
|
||||||
)
|
);
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let basic = Arg::new("basic")
|
let basic = Arg::new("basic")
|
||||||
.short('b')
|
.short('b')
|
||||||
|
@ -124,54 +129,45 @@ impl CommandBuilder for Command {
|
||||||
.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. Design is largely inspired by htop's.",
|
"Hides graphs and uses a more basic look. Design is largely inspired by htop's.",
|
||||||
)
|
);
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let disable_click = Arg::new("disable_click")
|
let disable_click = Arg::new("disable_click")
|
||||||
.long("disable_click")
|
.long("disable_click")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Disables mouse clicks.")
|
.help("Disables mouse clicks.")
|
||||||
.long_help("Disables mouse clicks from interacting with the program.")
|
.long_help("Disables mouse clicks from interacting with the program.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let dot_marker = Arg::new("dot_marker")
|
let dot_marker = Arg::new("dot_marker")
|
||||||
.short('m')
|
.short('m')
|
||||||
.long("dot_marker")
|
.long("dot_marker")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Uses a dot marker for graphs.")
|
.help("Uses a dot marker for graphs.")
|
||||||
.long_help("Uses a dot marker for graphs as opposed to the default braille marker.")
|
.long_help("Uses a dot marker for graphs as opposed to the default braille marker.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let hide_table_gap = Arg::new("hide_table_gap")
|
let hide_table_gap = Arg::new("hide_table_gap")
|
||||||
.long("hide_table_gap")
|
.long("hide_table_gap")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Hides spacing between table headers and entries.")
|
.help("Hides spacing between table headers and entries.")
|
||||||
.long_help("Hides the spacing between table headers and entries.")
|
.long_help("Hides the spacing between table headers and entries.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let hide_time = Arg::new("hide_time")
|
let hide_time = Arg::new("hide_time")
|
||||||
.long("hide_time")
|
.long("hide_time")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Hides the time scale.")
|
.help("Hides the time scale.")
|
||||||
.long_help("Completely hides the time scale from being shown.")
|
.long_help("Completely hides the time scale from being shown.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let left_legend = Arg::new("left_legend")
|
let left_legend = Arg::new("left_legend")
|
||||||
.short('l')
|
.short('l')
|
||||||
.long("left_legend")
|
.long("left_legend")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Puts the CPU chart legend to the left side.")
|
.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.")
|
.long_help("Puts the CPU chart legend to the left side rather than the right side.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let show_table_scroll_position = Arg::new("show_table_scroll_position")
|
let show_table_scroll_position = Arg::new("show_table_scroll_position")
|
||||||
.long("show_table_scroll_position")
|
.long("show_table_scroll_position")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Shows the scroll position tracker in table widgets.")
|
.help("Shows the scroll position tracker in table widgets.")
|
||||||
.long_help(
|
.long_help("Shows the list scroll position tracker in the widget title for table widgets.");
|
||||||
"Shows the list scroll position tracker in the widget title for table widgets.",
|
|
||||||
)
|
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let config_location = Arg::new("config_location")
|
let config_location = Arg::new("config_location")
|
||||||
.short('C')
|
.short('C')
|
||||||
|
@ -179,12 +175,8 @@ impl CommandBuilder for Command {
|
||||||
.action(ArgAction::Set)
|
.action(ArgAction::Set)
|
||||||
.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. If it doesn't exist, one is created.")
|
||||||
"Sets the location of the config file. Expects a config file in the TOML format. \
|
.value_hint(ValueHint::AnyPath);
|
||||||
If it doesn't exist, one is created.",
|
|
||||||
)
|
|
||||||
.value_hint(ValueHint::AnyPath)
|
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let default_time_value = Arg::new("default_time_value")
|
let default_time_value = Arg::new("default_time_value")
|
||||||
.short('t')
|
.short('t')
|
||||||
|
@ -192,10 +184,7 @@ impl CommandBuilder for Command {
|
||||||
.action(ArgAction::Set)
|
.action(ArgAction::Set)
|
||||||
.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 duration (e.g. 60s). The minimum time is 30s, and the default is 60s.");
|
||||||
"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.",
|
|
||||||
)
|
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
// TODO: Charts are broken in the manpage
|
// TODO: Charts are broken in the manpage
|
||||||
let default_widget_count = Arg::new("default_widget_count")
|
let default_widget_count = Arg::new("default_widget_count")
|
||||||
|
@ -222,24 +211,21 @@ And we set our default widget type to 'CPU'. If we set
|
||||||
the default widget. If we set '--default_widget_count 3', it would
|
the default widget. If we set '--default_widget_count 3', it would
|
||||||
use CPU (3) as the default instead.
|
use CPU (3) as the default instead.
|
||||||
",
|
",
|
||||||
)
|
);
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
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 TYPE")
|
||||||
.help("Sets the default widget type, use --help for info.")
|
.help("Sets the default widget type, use --help for info.")
|
||||||
.long_help(DEFAULT_WIDGET_TYPE_STR)
|
.long_help(DEFAULT_WIDGET_TYPE_STR);
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let expanded_on_startup = Arg::new("expanded_on_startup")
|
let expanded_on_startup = Arg::new("expanded_on_startup")
|
||||||
.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("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 desired expanded widget. This flag has no effect in basic mode (--basic)")
|
.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 desired expanded widget. This flag has no effect in basic mode (--basic).");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let rate = Arg::new("rate")
|
let rate = Arg::new("rate")
|
||||||
.short('r')
|
.short('r')
|
||||||
|
@ -247,8 +233,7 @@ use CPU (3) as the default instead.
|
||||||
.action(ArgAction::Set)
|
.action(ArgAction::Set)
|
||||||
.value_name("TIME")
|
.value_name("TIME")
|
||||||
.help("Sets the data refresh rate.")
|
.help("Sets the data refresh rate.")
|
||||||
.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.")
|
.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.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let time_delta = Arg::new("time_delta")
|
let time_delta = Arg::new("time_delta")
|
||||||
.short('d')
|
.short('d')
|
||||||
|
@ -256,18 +241,16 @@ use CPU (3) as the default instead.
|
||||||
.action(ArgAction::Set)
|
.action(ArgAction::Set)
|
||||||
.value_name("TIME")
|
.value_name("TIME")
|
||||||
.help("The amount of time changed upon zooming.")
|
.help("The amount of time changed upon zooming.")
|
||||||
.long_help("The amount of time changed when zooming in/out. Takes a number in milliseconds or a human duration (e.g. 30s). The minimum is 1s, and defaults to 15s.")
|
.long_help("The amount of time changed when zooming in/out. Takes a number in milliseconds or a human duration (e.g. 30s). The minimum is 1s, and defaults to 15s.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let retention = Arg::new("retention")
|
let retention = Arg::new("retention")
|
||||||
.long("retention")
|
.long("retention")
|
||||||
.action(ArgAction::Set)
|
.action(ArgAction::Set)
|
||||||
.value_name("TIME")
|
.value_name("TIME")
|
||||||
.help("The timespan of data stored.")
|
.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 higher values will take up more memory. Defaults to 10 minutes.")
|
.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 higher values will take up more memory. Defaults to 10 minutes.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let mut args = [
|
cmd.args(args![
|
||||||
autohide_time,
|
autohide_time,
|
||||||
basic,
|
basic,
|
||||||
disable_click,
|
disable_click,
|
||||||
|
@ -284,14 +267,11 @@ use CPU (3) as the default instead.
|
||||||
rate,
|
rate,
|
||||||
time_delta,
|
time_delta,
|
||||||
retention,
|
retention,
|
||||||
];
|
])
|
||||||
args.sort_unstable();
|
|
||||||
|
|
||||||
self.args(args)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn style_args(self) -> Command {
|
fn style_args(cmd: Command) -> Command {
|
||||||
const HEADING: &str = "Style Options";
|
let cmd = cmd.next_help_heading("Style Options");
|
||||||
|
|
||||||
// TODO: File an issue with manpage, it cannot render charts correctly.
|
// TODO: File an issue with manpage, it cannot render charts correctly.
|
||||||
let color = Arg::new("color")
|
let color = Arg::new("color")
|
||||||
|
@ -326,36 +306,32 @@ Use a pre-defined color scheme. Currently supported values are:
|
||||||
+------------------------------------------------------------+
|
+------------------------------------------------------------+
|
||||||
Defaults to \"default\".
|
Defaults to \"default\".
|
||||||
",
|
",
|
||||||
)
|
);
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
self.arg(color)
|
cmd.arg(color)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn temperature_args(self) -> Command {
|
fn temperature_args(cmd: Command) -> Command {
|
||||||
const HEADING: &str = "Temperature Options";
|
let cmd = cmd.next_help_heading("Temperature Options");
|
||||||
|
|
||||||
let celsius = Arg::new("celsius")
|
let celsius = Arg::new("celsius")
|
||||||
.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.")
|
||||||
.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.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let fahrenheit = Arg::new("fahrenheit")
|
let fahrenheit = Arg::new("fahrenheit")
|
||||||
.short('f')
|
.short('f')
|
||||||
.long("fahrenheit")
|
.long("fahrenheit")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Use Fahrenheit as the temperature unit.")
|
.help("Use Fahrenheit as the temperature unit.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let kelvin = Arg::new("kelvin")
|
let kelvin = Arg::new("kelvin")
|
||||||
.short('k')
|
.short('k')
|
||||||
.long("kelvin")
|
.long("kelvin")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Use Kelvin as the temperature unit.")
|
.help("Use Kelvin as the temperature unit.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let temperature_group = ArgGroup::new("TEMPERATURE_TYPE").args([
|
let temperature_group = ArgGroup::new("TEMPERATURE_TYPE").args([
|
||||||
celsius.get_id(),
|
celsius.get_id(),
|
||||||
|
@ -363,69 +339,59 @@ Defaults to \"default\".
|
||||||
kelvin.get_id(),
|
kelvin.get_id(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let args = [celsius, fahrenheit, kelvin];
|
cmd.args(args![celsius, fahrenheit, kelvin])
|
||||||
|
.group(temperature_group)
|
||||||
self.args(args).group(temperature_group)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_args(self) -> Command {
|
fn process_args(cmd: Command) -> Command {
|
||||||
const HEADING: &str = "Process Options";
|
let cmd = cmd.next_help_heading("Process Options");
|
||||||
|
|
||||||
let case_sensitive = Arg::new("case_sensitive")
|
let case_sensitive = Arg::new("case_sensitive")
|
||||||
.short('S')
|
.short('S')
|
||||||
.long("case_sensitive")
|
.long("case_sensitive")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Enables case sensitivity by default.")
|
.help("Enables case sensitivity by default.")
|
||||||
.long_help("When searching for a process, enables case sensitivity by default.")
|
.long_help("When searching for a process, enables case sensitivity by default.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let current_usage = Arg::new("current_usage")
|
let current_usage = Arg::new("current_usage")
|
||||||
.short('u')
|
.short('u')
|
||||||
.long("current_usage")
|
.long("current_usage")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Sets process CPU% to be based on current CPU%.")
|
.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.")
|
.long_help("Sets process CPU% usage to be based on the current system CPU% usage rather than total CPU usage.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let unnormalized_cpu = Arg::new("unnormalized_cpu")
|
let unnormalized_cpu = Arg::new("unnormalized_cpu")
|
||||||
.short('n')
|
.short('n')
|
||||||
.long("unnormalized_cpu")
|
.long("unnormalized_cpu")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Show process CPU% usage without normalizing over the number of cores.")
|
.help("Show process CPU% usage without normalizing over the number of cores.")
|
||||||
.long_help(
|
.long_help("Shows all process CPU% usage without averaging over the number of CPU cores in the system.");
|
||||||
"Shows all process CPU% usage without averaging over the number of CPU cores in the system.",
|
|
||||||
)
|
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let group_processes = Arg::new("group_processes")
|
let group_processes = Arg::new("group_processes")
|
||||||
.short('g')
|
.short('g')
|
||||||
.long("group_processes")
|
.long("group_processes")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Groups processes with the same name by default.")
|
.help("Groups processes with the same name by default.")
|
||||||
.long_help("Groups processes with the same name by default.")
|
.long_help("Groups processes with the same name by default.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let process_command = Arg::new("process_command")
|
let process_command = Arg::new("process_command")
|
||||||
.long("process_command")
|
.long("process_command")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Show processes as their commands by default.")
|
.help("Show processes as their commands by default.")
|
||||||
.long_help("Show processes as their commands by default in the process widget.")
|
.long_help("Show processes as their commands by default in the process widget.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let regex = Arg::new("regex")
|
let regex = Arg::new("regex")
|
||||||
.short('R')
|
.short('R')
|
||||||
.long("regex")
|
.long("regex")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Enables regex by default.")
|
.help("Enables regex by default.")
|
||||||
.long_help("When searching for a process, enables regex by default.")
|
.long_help("When searching for a process, enables regex by default.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let disable_advanced_kill = Arg::new("disable_advanced_kill")
|
let disable_advanced_kill = Arg::new("disable_advanced_kill")
|
||||||
.long("disable_advanced_kill")
|
.long("disable_advanced_kill")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Hides advanced process killing.")
|
.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).")
|
.long_help("Hides advanced options to stop a process on Unix-like systems. The only option shown is 15 (TERM).");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let whole_word = Arg::new("whole_word")
|
let whole_word = Arg::new("whole_word")
|
||||||
.short('W')
|
.short('W')
|
||||||
|
@ -434,18 +400,16 @@ Defaults to \"default\".
|
||||||
.help("Enables whole-word matching by default.")
|
.help("Enables whole-word matching by default.")
|
||||||
.long_help(
|
.long_help(
|
||||||
"When searching for a process, return results that match the entire query by default.",
|
"When searching for a process, return results that match the entire query by default.",
|
||||||
)
|
);
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let tree = Arg::new("tree")
|
let tree = Arg::new("tree")
|
||||||
.short('T')
|
.short('T')
|
||||||
.long("tree")
|
.long("tree")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Defaults the process widget be in tree mode.")
|
.help("Defaults the process widget be in tree mode.")
|
||||||
.long_help("Defaults to showing the process widget in tree mode.")
|
.long_help("Defaults to showing the process widget in tree mode.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let mut args = [
|
let args = args![
|
||||||
case_sensitive,
|
case_sensitive,
|
||||||
current_usage,
|
current_usage,
|
||||||
unnormalized_cpu,
|
unnormalized_cpu,
|
||||||
|
@ -456,155 +420,127 @@ Defaults to \"default\".
|
||||||
disable_advanced_kill,
|
disable_advanced_kill,
|
||||||
tree,
|
tree,
|
||||||
];
|
];
|
||||||
args.sort_unstable();
|
|
||||||
|
|
||||||
self.args(args)
|
cmd.args(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cpu_args(self) -> Command {
|
fn cpu_args(cmd: Command) -> Command {
|
||||||
const HEADING: &str = "CPU Options";
|
let cmd = cmd.next_help_heading("CPU Options");
|
||||||
|
|
||||||
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.")
|
||||||
.long_help("Hides the average CPU usage from being shown.")
|
.long_help("Hides the average CPU usage from being shown.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
self.arg(hide_avg_cpu)
|
// let default_avg_cpu = Arg::new("");
|
||||||
|
|
||||||
|
cmd.args(args![hide_avg_cpu])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mem_args(self) -> Command {
|
fn mem_args(cmd: Command) -> Command {
|
||||||
const HEADING: &str = "Memory Options";
|
let cmd = cmd.next_help_heading("Memory Options");
|
||||||
|
|
||||||
let mem_as_value = Arg::new("mem_as_value")
|
let mem_as_value = Arg::new("mem_as_value")
|
||||||
.long("mem_as_value")
|
.long("mem_as_value")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Defaults to showing process memory usage by value.")
|
.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.")
|
.long_help("Defaults to showing process memory usage by value. Otherwise, it defaults to showing it by percentage.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
{
|
{
|
||||||
let enable_cache_memory = Arg::new("enable_cache_memory")
|
let enable_cache_memory = Arg::new("enable_cache_memory")
|
||||||
.long("enable_cache_memory")
|
.long("enable_cache_memory")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Enable collecting and displaying cache and buffer memory.")
|
.help("Enable collecting and displaying cache and buffer memory.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
self.args([mem_as_value, enable_cache_memory])
|
cmd.args(args![mem_as_value, enable_cache_memory])
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
self.arg(mem_as_value)
|
cmd.arg(mem_as_value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn network_args(self) -> Command {
|
fn network_args(cmd: Command) -> Command {
|
||||||
const HEADING: &str = "Network Options";
|
let cmd = cmd.next_help_heading("Network Options");
|
||||||
|
|
||||||
let use_old_network_legend = Arg::new("use_old_network_legend")
|
let use_old_network_legend = Arg::new("use_old_network_legend")
|
||||||
.long("use_old_network_legend")
|
.long("use_old_network_legend")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("DEPRECATED - uses a separate network legend.")
|
.help("DEPRECATED - uses a separate network legend.")
|
||||||
.long_help(
|
.long_help("DEPRECATED - uses an older (pre-0.4), separate network widget legend. This display is not tested anymore and may be broken.");
|
||||||
"DEPRECATED - uses an older (pre-0.4), separate network widget legend. This display is not \
|
|
||||||
tested anymore and could be broken.",
|
|
||||||
)
|
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
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")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.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.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
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.");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let network_use_binary_prefix = Arg::new("network_use_binary_prefix")
|
let network_use_binary_prefix = Arg::new("network_use_binary_prefix")
|
||||||
.long("network_use_binary_prefix")
|
.long("network_use_binary_prefix")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Displays the network widget with binary prefixes.")
|
.help("Displays the network widget with binary prefixes.")
|
||||||
.long_help(
|
.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.");
|
||||||
"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_heading(HEADING);
|
|
||||||
|
|
||||||
let mut args = [
|
cmd.args(args![
|
||||||
use_old_network_legend,
|
use_old_network_legend,
|
||||||
network_use_bytes,
|
network_use_bytes,
|
||||||
network_use_log,
|
network_use_log,
|
||||||
network_use_binary_prefix,
|
network_use_binary_prefix,
|
||||||
];
|
])
|
||||||
|
|
||||||
args.sort_unstable();
|
|
||||||
|
|
||||||
self.args(args)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn battery_args(self) -> Command {
|
|
||||||
#[cfg(feature = "battery")]
|
#[cfg(feature = "battery")]
|
||||||
{
|
fn battery_args(cmd: Command) -> Command {
|
||||||
|
let cmd = cmd.next_help_heading("Battery Options");
|
||||||
|
|
||||||
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.")
|
||||||
.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. No effect on custom layouts.",
|
||||||
)
|
);
|
||||||
.help_heading("Battery Options");
|
|
||||||
|
|
||||||
self.arg(battery)
|
cmd.arg(battery)
|
||||||
}
|
|
||||||
#[cfg(not(feature = "battery"))]
|
|
||||||
{
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gpu_args(self) -> Command {
|
|
||||||
#[cfg(feature = "gpu")]
|
#[cfg(feature = "gpu")]
|
||||||
{
|
fn gpu_args(cmd: Command) -> Command {
|
||||||
|
let cmd = cmd.next_help_heading("GPU Options");
|
||||||
|
|
||||||
let enable_gpu = Arg::new("enable_gpu")
|
let enable_gpu = Arg::new("enable_gpu")
|
||||||
.long("enable_gpu")
|
.long("enable_gpu")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.help("Enable collecting and displaying GPU usage.")
|
.help("Enable collecting and displaying GPU usage.");
|
||||||
.help_heading("GPU Options");
|
|
||||||
|
|
||||||
self.arg(enable_gpu)
|
cmd.arg(enable_gpu)
|
||||||
}
|
|
||||||
#[cfg(not(feature = "gpu"))]
|
|
||||||
{
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn other(self) -> Command {
|
fn other_args(cmd: Command) -> Command {
|
||||||
const HEADING: &str = "Other Options";
|
let cmd = cmd.next_help_heading("Other Options");
|
||||||
|
|
||||||
let version = Arg::new("version")
|
|
||||||
.short('V')
|
|
||||||
.long("version")
|
|
||||||
.action(ArgAction::Version)
|
|
||||||
.help("Prints version information.")
|
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
let help = Arg::new("help")
|
let help = Arg::new("help")
|
||||||
.short('h')
|
.short('h')
|
||||||
.long("help")
|
.long("help")
|
||||||
.action(ArgAction::Help)
|
.action(ArgAction::Help)
|
||||||
.help("Prints help (see more with '--help').")
|
.help("Prints help (see more info with '--help').");
|
||||||
.help_heading(HEADING);
|
|
||||||
|
|
||||||
self.args([version, help])
|
let version = Arg::new("version")
|
||||||
}
|
.short('V')
|
||||||
|
.long("version")
|
||||||
|
.action(ArgAction::Version)
|
||||||
|
.help("Prints version information.");
|
||||||
|
|
||||||
|
cmd.args([help, version])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_app() -> Command {
|
pub fn build_app() -> Command {
|
||||||
|
@ -615,7 +551,7 @@ pub fn build_app() -> Command {
|
||||||
None => crate_version!(),
|
None => crate_version!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Command::new(crate_name!())
|
let cmd = Command::new(crate_name!())
|
||||||
.author(crate_authors!())
|
.author(crate_authors!())
|
||||||
.about(crate_description!())
|
.about(crate_description!())
|
||||||
.disable_help_flag(true)
|
.disable_help_flag(true)
|
||||||
|
@ -623,17 +559,24 @@ pub fn build_app() -> Command {
|
||||||
.color(ColorChoice::Auto)
|
.color(ColorChoice::Auto)
|
||||||
.help_template(TEMPLATE)
|
.help_template(TEMPLATE)
|
||||||
.override_usage(USAGE)
|
.override_usage(USAGE)
|
||||||
.version(VERSION)
|
.version(VERSION);
|
||||||
.general_args()
|
|
||||||
.style_args()
|
[
|
||||||
.temperature_args()
|
general_args,
|
||||||
.process_args()
|
process_args,
|
||||||
.cpu_args()
|
temperature_args,
|
||||||
.mem_args()
|
cpu_args,
|
||||||
.network_args()
|
mem_args,
|
||||||
.battery_args()
|
network_args,
|
||||||
.gpu_args()
|
#[cfg(feature = "battery")]
|
||||||
.other()
|
battery_args,
|
||||||
|
#[cfg(feature = "gpu")]
|
||||||
|
gpu_args,
|
||||||
|
style_args,
|
||||||
|
other_args,
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.fold(cmd, |c, f| f(c))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -646,7 +589,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn help_heading_no_default() {
|
fn no_default_help_heading() {
|
||||||
let mut app = build_app();
|
let mut app = build_app();
|
||||||
let help_str = app.render_help();
|
let help_str = app.render_help();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue