diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2022-03-07 22:53:02 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-07 22:53:02 -0500 |
commit | 01f6bddab63d5d1d61baa9e90a326ffe2696762b (patch) | |
tree | f253911faf60aaca27a6a677cf0e7de1f0b53268 /src | |
parent | e682882aeeb09e721f074bc8545770208c3c5321 (diff) |
deps: update clap to 3.x (#690)
Updates bottom to use clap 3.x, along with some small refactoring changes.
Diffstat (limited to 'src')
-rw-r--r-- | src/clap.rs | 348 | ||||
-rw-r--r-- | src/options.rs | 66 |
2 files changed, 162 insertions, 252 deletions
diff --git a/src/clap.rs b/src/clap.rs index 8604c5a8..282b79b2 100644 --- a/src/clap.rs +++ b/src/clap.rs @@ -9,7 +9,7 @@ const TEMPLATE: &str = "\ USAGE:{usage} FLAGS: -{unified}"; +{options}"; const USAGE: &str = " btm [FLAG]"; @@ -46,7 +46,7 @@ Supported widget names: +--------------------------+ | batt, battery | +--------------------------+ -\n\n" +" } else { "\ Sets which widget type to use as the default widget. @@ -77,229 +77,171 @@ Supported widget names: +--------------------------+ | disk | +--------------------------+ -\n\n" +" }; -pub fn get_matches() -> clap::ArgMatches<'static> { +pub fn get_matches() -> clap::ArgMatches { build_app().get_matches() } // TODO: Refactor this a bit, it's quite messy atm -pub fn build_app() -> App<'static, 'static> { +pub fn build_app() -> Command<'static> { // Temps - let kelvin = Arg::with_name("kelvin") - .short("k") + let kelvin = Arg::new("kelvin") + .short('k') .long("kelvin") .help("Sets the temperature type to Kelvin.") - .long_help( - "\ -Sets the temperature type to Kelvin.\n\n", - ); - let fahrenheit = Arg::with_name("fahrenheit") - .short("f") + .long_help("Sets the temperature type to Kelvin."); + + let fahrenheit = Arg::new("fahrenheit") + .short('f') .long("fahrenheit") .help("Sets the temperature type to Fahrenheit.") - .long_help( - "\ -Sets the temperature type to Fahrenheit.\n\n", - ); - let celsius = Arg::with_name("celsius") - .short("c") + .long_help("Sets the temperature type to Fahrenheit."); + + let celsius = Arg::new("celsius") + .short('c') .long("celsius") .help("Sets the temperature type to Celsius.") - .long_help( - "\ -Sets the temperature type to Celsius. This is the default -option.\n\n", - ); + .long_help("Sets the temperature type to Celsius. This is the default option."); - // All flags. These are in alphabetical order - let autohide_time = Arg::with_name("autohide_time") + // All flags. These are in alphabetical order + let autohide_time = Arg::new("autohide_time") .long("autohide_time") .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.\n\n\n", + "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::with_name("basic") - .short("b") + + let basic = Arg::new("basic") + .short('b') .long("basic") .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.\n\n", + "Hides graphs and uses a more basic look. Design is largely inspired by htop's.", ); - let case_sensitive = Arg::with_name("case_sensitive") - .short("S") + + let case_sensitive = Arg::new("case_sensitive") + .short('S') .long("case_sensitive") .help("Enables case sensitivity by default.") - .long_help( - "\ -When searching for a process, enables case sensitivity by default.\n\n", - ); - let current_usage = Arg::with_name("current_usage") - .short("u") + .long_help("When searching for a process, enables case sensitivity by default."); + + let current_usage = Arg::new("current_usage") + .short('u') .long("current_usage") .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.\n\n", - ); + .long_help("Sets process CPU% usage to be based on the current system CPU% usage rather than total CPU usage."); + // TODO: [DEBUG] Add a proper debugging solution. - // let debug = Arg::with_name("debug") - // .long("debug") - // .help("Enables debug logging.") - // .long_help( - // "\ - // Enables debug logging. The program will print where it logged to after running.", - // ); - // TODO: [DIAGNOSE] Add a diagnose option to help with debugging. - let disable_click = Arg::with_name("disable_click") + + let disable_click = Arg::new("disable_click") .long("disable_click") .help("Disables mouse clicks.") - .long_help( - "\ -Disables mouse clicks from interacting with the program.\n\n", - ); + .long_help("Disables mouse clicks from interacting with the program."); - let dot_marker = Arg::with_name("dot_marker") - .short("m") + let dot_marker = Arg::new("dot_marker") + .short('m') .long("dot_marker") .help("Uses a dot marker for graphs.") - .long_help( - "\ -Uses a dot marker for graphs as opposed to the default braille -marker.\n\n", - ); + .long_help("Uses a dot marker for graphs as opposed to the default braille marker."); - let group = Arg::with_name("group") // FIXME: Rename this to something like "group_process", would be "breaking" though. - .short("g") + let group = Arg::new("group") // FIXME: Rename this to something like "group_process", would be "breaking" though. + .short('g') .long("group") .help("Groups processes with the same name by default.") - .long_help( - "\ -Groups processes with the same name by default.\n\n", - ); + .long_help("Groups processes with the same name by default."); - let hide_avg_cpu = Arg::with_name("hide_avg_cpu") - .short("a") + let hide_avg_cpu = Arg::new("hide_avg_cpu") + .short('a') .long("hide_avg_cpu") .help("Hides the average CPU usage.") - .long_help( - "\ -Hides the average CPU usage from being shown.\n\n", - ); + .long_help("Hides the average CPU usage from being shown."); - let hide_table_gap = Arg::with_name("hide_table_gap") + let hide_table_gap = Arg::new("hide_table_gap") .long("hide_table_gap") .help("Hides the spacing between table headers and entries.") - .long_help( - "\ -Hides the spacing between table headers and entries.\n\n", - ); + .long_help("Hides the spacing between table headers and entries."); - let hide_time = Arg::with_name("hide_time") + let hide_time = Arg::new("hide_time") .long("hide_time") .help("Hides the time scale.") - .long_help( - "\ -Completely hides the time scale from being shown.\n\n", - ); + .long_help("Completely hides the time scale from being shown."); - let process_command = Arg::with_name("process_command") + let process_command = Arg::new("process_command") .long("process_command") .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."); - let left_legend = Arg::with_name("left_legend") - .short("l") + let left_legend = Arg::new("left_legend") + .short('l') .long("left_legend") .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.\n\n", - ); + .long_help("Puts the CPU chart legend to the left side rather than the right side."); - // let no_write = Arg::with_name("no_write") - // .long("no_write") - // .help("Disables writing to the config file.") - // .long_help( - // "\ - // Disables config changes in-app from writing to the config file.", - // ); - - let regex = Arg::with_name("regex") - .short("R") + let regex = Arg::new("regex") + .short('R') .long("regex") .help("Enables regex by default.") - .long_help( - "\ -When searching for a process, enables regex by default.\n\n", - ); + .long_help("When searching for a process, enables regex by default."); - let disable_advanced_kill = Arg::with_name("disable_advanced_kill") + let disable_advanced_kill = Arg::new("disable_advanced_kill") .long("disable_advanced_kill") .help("Hides advanced options to stop a process on Unix-like systems.") - .long_help( - "\ -Hides advanced options to stop a process on Unix-like systems. The only option shown is -15.\n\n", - ); + .long_help("Hides advanced options to stop a process on Unix-like systems. The only option shown is -15."); - let show_table_scroll_position = Arg::with_name("show_table_scroll_position") + let show_table_scroll_position = Arg::new("show_table_scroll_position") .long("show_table_scroll_position") .help("Shows the scroll position tracker in table widgets.") - .long_help( - "\ - Shows the list scroll position tracker in the widget title for table widgets.\n\n", - ); + .long_help("Shows the list scroll position tracker in the widget title for table widgets."); - let use_old_network_legend = Arg::with_name("use_old_network_legend") + let use_old_network_legend = Arg::new("use_old_network_legend") .long("use_old_network_legend") - .help("DEPRECATED - uses the older network legend.") + .help("DEPRECATED - uses a separate network legend.") .long_help( - "\ -DEPRECATED - uses the older (pre-0.4) network widget legend. -This display is not tested anymore and could be broken.\n\n\n", + "DEPRECATED - uses an older (pre-0.4), separate network widget legend. This display is not \ + tested anymore and could be broken.", ); - let whole_word = Arg::with_name("whole_word") - .short("W") + let whole_word = Arg::new("whole_word") + .short('W') .long("whole_word") .help("Enables whole-word matching by default.") .long_help( - "\ -When searching for a process, return results that match the -entire query by default.\n\n", + "When searching for a process, return results that match the entire query by default.", ); - // All options. Again, alphabetical order. - let config_location = Arg::with_name("config_location") - .short("C") + // All options. Again, alphabetical order. + let config_location = Arg::new("config_location") + .short('C') .long("config") .takes_value(true) .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.\n\n\n", + "Sets the location of the config file. Expects a config file in the TOML format. \ + If it doesn't exist, one is created.", ); - let color = Arg::with_name("color") + + let color = Arg::new("color") .long("color") .takes_value(true) .value_name("COLOR SCHEME") + .possible_values(&[ + "default", + "default-light", + "gruvbox", + "gruvbox-light", + "nord", + "nord-light", + ]) + .hide_possible_values(true) .help("Use a color scheme, use --help for supported values.") .long_help( "\ -Use a pre-defined color scheme. Currently supported values are: +Use a pre-defined color scheme. Currently supported values are: +------------------------------------------------------------+ | default | @@ -316,37 +258,23 @@ Use a pre-defined color scheme. Currently supported values are: +------------------------------------------------------------+ Defaults to \"default\". -\n\n", - ) - .possible_values(&[ - "default", - "default-light", - "gruvbox", - "gruvbox-light", - "nord", - "nord-light", - ]) - .hide_possible_values(true); - let mem_as_value = Arg::with_name("mem_as_value") +", + ); + + let mem_as_value = Arg::new("mem_as_value") .long("mem_as_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.\n\n", - ); - let default_time_value = Arg::with_name("default_time_value") - .short("t") + .long_help("Defaults to showing process memory usage by value. Otherwise, it defaults to showing it by percentage."); + + let default_time_value = Arg::new("default_time_value") + .short('t') .long("default_time_value") .takes_value(true) .value_name("MS") .help("Default time value for graphs in ms.") - .long_help( - "\ -Default time value for graphs in milliseconds. The minimum -time is 30s (30000), and the default is 60s (60000).\n\n\n", - ); - let default_widget_count = Arg::with_name("default_widget_count") + .long_help("Default time value for graphs in milliseconds. The minimum time is 30s (30000), and the default is 60s (60000)."); + + let default_widget_count = Arg::new("default_widget_count") .long("default_widget_count") .takes_value(true) .requires_all(&["default_widget_type"]) @@ -357,7 +285,7 @@ time is 30s (30000), and the default is 60s (60000).\n\n\n", 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 +This reads from left to right, top to bottom. For example, suppose we have a layout that looks like: +-------------------+-----------------------+ | CPU (1) | CPU (2) | @@ -365,87 +293,73 @@ we have a layout that looks like: | Process | CPU (3) | Temperature | CPU (4) | +---------+---------+-------------+---------+ -And we set our default widget type to 'CPU'. If we set +And we set our default widget type to 'CPU'. If we set '--default_widget_count 1', then it would use the CPU (1) as -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. -\n\n", +", ); - let default_widget_type = Arg::with_name("default_widget_type") + + let default_widget_type = Arg::new("default_widget_type") .long("default_widget_type") .takes_value(true) .value_name("WIDGET TYPE") .help("Sets the default widget type, use --help for more info.") .long_help(DEFAULT_WIDGET_TYPE_STR); - let rate = Arg::with_name("rate") - .short("r") + + let rate = Arg::new("rate") + .short('r') .long("rate") .takes_value(true) .value_name("MS") .help("Sets a refresh rate in ms.") - .long_help( - "\ -Sets a refresh rate in milliseconds. The minimum is 250ms, -and defaults to 1000ms. Smaller values may take more resources.\n\n\n", - ); - let time_delta = Arg::with_name("time_delta") - .short("d") + .long_help("Sets a refresh rate in milliseconds. The minimum is 250ms, and defaults to 1000ms. Smaller values may take more computer resources."); + + let time_delta = Arg::new("time_delta") + .short('d') .long("time_delta") .takes_value(true) .value_name("MS") .help("The amount in ms changed upon zooming.") - .long_help( - "\ -The amount of time in milliseconds changed when zooming in/out. -The minimum is 1s (1000), and defaults to 15s (15000).\n\n\n", - ); + .long_help("The amount of time in milliseconds changed when zooming in/out. The minimum is 1s (1000), and defaults to 15s (15000)."); - let tree = Arg::with_name("tree") - .short("T") + let tree = Arg::new("tree") + .short('T') .long("tree") .help("Defaults to showing the process widget in tree mode.") - .long_help( - "\ -Defaults to showing the process widget in tree mode.\n\n", - ); + .long_help("Defaults to showing the process widget in tree mode."); - let network_use_bytes = Arg::with_name("network_use_bytes") + let network_use_bytes = Arg::new("network_use_bytes") .long("network_use_bytes") .help("Displays the network widget using bytes.") - .long_help( - "\ -Displays the network widget using bytes. Defaults to bits.\n\n", - ); + .long_help("Displays the network widget using bytes. Defaults to bits."); - let network_use_log = Arg::with_name("network_use_log") + let network_use_log = Arg::new("network_use_log") .long("network_use_log") .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.\n\n", - ); + .long_help("Displays the network widget with a log scale. Defaults to a non-log scale."); - let network_use_binary_prefix = Arg::with_name("network_use_binary_prefix") + let network_use_binary_prefix = Arg::new("network_use_binary_prefix") .long("network_use_binary_prefix") .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.\n\n\n", + "Displays the network widget with binary prefixes (i.e. kibibits, mebibits) rather than a decimal prefix (i.e. kilobits, megabits). Defaults to decimal prefixes.", ); - let app = App::new(crate_name!()) - .setting(AppSettings::UnifiedHelpMessage) + let app = Command::new(crate_name!()) .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.") + .override_usage(USAGE) + .help_template(TEMPLATE) + .mut_arg("help", |a| { + a.help("Prints help information. Use --help for more info.") + }) + .mut_arg("version", |a| a.help("Prints version information.")) .arg(kelvin) .arg(fahrenheit) .arg(celsius) - .group(ArgGroup::with_name("TEMPERATURE_TYPE").args(&["kelvin", "fahrenheit", "celsius"])) + .group(ArgGroup::new("TEMPERATURE_TYPE").args(&["kelvin", "fahrenheit", "celsius"])) .arg(autohide_time) .arg(basic) .arg(case_sensitive) @@ -477,13 +391,11 @@ Displays the network widget with binary prefixes (i.e. kibibits, mebibits) rathe .arg(whole_word); let app = if cfg!(feature = "battery") { - let battery = Arg::with_name("battery") + let battery = Arg::new("battery") .long("battery") .help("Shows the battery widget.") .long_help( - "\ -Shows the battery widget in default or basic mode. No effect on -custom layouts.\n\n", + "Shows the battery widget in default or basic mode. No effect on custom layouts.", ); app.arg(battery) } else { diff --git a/src/options.rs b/src/options.rs index bdbc7e60..d469dc69 100644 --- a/src/options.rs +++ b/src/options.rs @@ -244,7 +244,7 @@ pub struct IgnoreList { } pub fn build_app( - matches: &clap::ArgMatches<'static>, config: &mut Config, widget_layout: &BottomLayout, + matches: &clap::ArgMatches, config: &mut Config, widget_layout: &BottomLayout, default_widget_id: u64, default_widget_type_option: &Option<BottomWidgetType>, config_path: Option<PathBuf>, ) -> Result<App> { @@ -524,7 +524,7 @@ pub fn build_app( } pub fn get_widget_layout( - matches: &clap::ArgMatches<'static>, config: &Config, + matches: &clap::ArgMatches, config: &Config, ) -> error::Result<(BottomLayout, u64, Option<BottomWidgetType>)> { let left_legend = get_use_left_legend(matches, config); let (default_widget_type, mut default_widget_count) = @@ -589,7 +589,7 @@ pub fn get_widget_layout( } fn get_update_rate_in_milliseconds( - matches: &clap::ArgMatches<'static>, config: &Config, + matches: &clap::ArgMatches, config: &Config, ) -> error::Result<u64> { let update_rate_in_milliseconds = if let Some(update_rate) = matches.value_of("rate") { update_rate.parse::<u128>()? @@ -617,7 +617,7 @@ fn get_update_rate_in_milliseconds( } fn get_temperature( - matches: &clap::ArgMatches<'static>, config: &Config, + matches: &clap::ArgMatches, config: &Config, ) -> error::Result<data_harvester::temperature::TemperatureType> { if matches.is_present("fahrenheit") { return Ok(data_harvester::temperature::TemperatureType::Fahrenheit); @@ -643,7 +643,7 @@ fn get_temperature( } /// Yes, this function gets whether to show average CPU (true) or not (false) -fn get_show_average_cpu(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_show_average_cpu(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("hide_avg_cpu") { return false; } else if let Some(flags) = &config.flags { @@ -655,7 +655,7 @@ fn get_show_average_cpu(matches: &clap::ArgMatches<'static>, config: &Config) -> true } -fn get_use_dot(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_use_dot(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("dot_marker") { return true; } else if let Some(flags) = &config.flags { @@ -666,7 +666,7 @@ fn get_use_dot(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { false } -fn get_use_left_legend(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_use_left_legend(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("left_legend") { return true; } else if let Some(flags) = &config.flags { @@ -678,7 +678,7 @@ fn get_use_left_legend(matches: &clap::ArgMatches<'static>, config: &Config) -> false } -fn get_use_current_cpu_total(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_use_current_cpu_total(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("current_usage") { return true; } else if let Some(flags) = &config.flags { @@ -690,7 +690,7 @@ fn get_use_current_cpu_total(matches: &clap::ArgMatches<'static>, config: &Confi false } -fn get_use_basic_mode(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_use_basic_mode(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("basic") { return true; } else if let Some(flags) = &config.flags { @@ -702,9 +702,7 @@ fn get_use_basic_mode(matches: &clap::ArgMatches<'static>, config: &Config) -> b false } -fn get_default_time_value( - matches: &clap::ArgMatches<'static>, config: &Config, -) -> error::Result<u64> { +fn get_default_time_value(matches: &clap::ArgMatches, config: &Config) -> error::Result<u64> { let default_time = if let Some(default_time_value) = matches.value_of("default_time_value") { default_time_value.parse::<u128>()? } else if let Some(flags) = &config.flags { @@ -731,7 +729,7 @@ fn get_default_time_value( Ok(default_time as u64) } -fn get_time_interval(matches: &clap::ArgMatches<'static>, config: &Config) -> error::Result<u64> { +fn get_time_interval(matches: &clap::ArgMatches, config: &Config) -> error::Result<u64> { let time_interval = if let Some(time_interval) = matches.value_of("time_delta") { time_interval.parse::<u128>()? } else if let Some(flags) = &config.flags { @@ -758,7 +756,7 @@ fn get_time_interval(matches: &clap::ArgMatches<'static>, config: &Config) -> er Ok(time_interval as u64) } -pub fn get_app_grouping(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +pub fn get_app_grouping(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("group") { return true; } else if let Some(flags) = &config.flags { @@ -769,7 +767,7 @@ pub fn get_app_grouping(matches: &clap::ArgMatches<'static>, config: &Config) -> false } -pub fn get_app_case_sensitive(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +pub fn get_app_case_sensitive(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("case_sensitive") { return true; } else if let Some(flags) = &config.flags { @@ -780,7 +778,7 @@ pub fn get_app_case_sensitive(matches: &clap::ArgMatches<'static>, config: &Conf false } -pub fn get_app_match_whole_word(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +pub fn get_app_match_whole_word(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("whole_word") { return true; } else if let Some(flags) = &config.flags { @@ -791,7 +789,7 @@ pub fn get_app_match_whole_word(matches: &clap::ArgMatches<'static>, config: &Co false } -pub fn get_app_use_regex(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +pub fn get_app_use_regex(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("regex") { return true; } else if let Some(flags) = &config.flags { @@ -802,7 +800,7 @@ pub fn get_app_use_regex(matches: &clap::ArgMatches<'static>, config: &Config) - false } -fn get_hide_time(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_hide_time(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("hide_time") { return true; } else if let Some(flags) = &config.flags { @@ -813,7 +811,7 @@ fn get_hide_time(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { false } -fn get_autohide_time(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_autohide_time(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("autohide_time") { return true; } else if let Some(flags) = &config.flags { @@ -826,7 +824,7 @@ fn get_autohide_time(matches: &clap::ArgMatches<'static>, config: &Config) -> bo } fn get_default_widget_and_count( - matches: &clap::ArgMatches<'static>, config: &Config, + matches: &clap::ArgMatches, config: &Config, ) -> error::Result<(Option<BottomWidgetType>, u64)> { let widget_type = if let Some(widget_type) = matches.value_of("default_widget_type") { let parsed_widget = widget_type.parse::<BottomWidgetType>()?; @@ -878,7 +876,7 @@ fn get_default_widget_and_count( } } -fn get_disable_click(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_disable_click(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("disable_click") { return true; } else if let Some(flags) = &config.flags { @@ -889,7 +887,7 @@ fn get_disable_click(matches: &clap::ArgMatches<'static>, config: &Config) -> bo false } -fn get_use_old_network_legend(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_use_old_network_legend(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("use_old_network_legend") { return true; } else if let Some(flags) = &config.flags { @@ -900,7 +898,7 @@ fn get_use_old_network_legend(matches: &clap::ArgMatches<'static>, config: &Conf false } -fn get_hide_table_gap(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_hide_table_gap(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("hide_table_gap") { return true; } else if let Some(flags) = &config.flags { @@ -911,7 +909,7 @@ fn get_hide_table_gap(matches: &clap::ArgMatches<'static>, config: &Config) -> b false } -fn get_use_battery(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_use_battery(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("battery") { return true; } else if let Some(flags) = &config.flags { @@ -923,7 +921,7 @@ fn get_use_battery(matches: &clap::ArgMatches<'static>, config: &Config) -> bool } #[allow(dead_code)] -fn get_no_write(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_no_write(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("no_write") { return true; } else if let Some(flags) = &config.flags { @@ -972,7 +970,7 @@ fn get_ignore_list(ignore_list: &Option<IgnoreList>) -> error::Result<Option<Fil } pub fn get_color_scheme( - matches: &clap::ArgMatches<'static>, config: &Config, + matches: &clap::ArgMatches, config: &Config, ) -> error::Result<ColourScheme> { if let Some(color) = matches.value_of("color") { // Highest priority is always command line flags... @@ -998,7 +996,7 @@ pub fn get_color_scheme( Ok(ColourScheme::Default) } -fn get_mem_as_value(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_mem_as_value(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("mem_as_value") { return true; } else if let Some(flags) = &config.flags { @@ -1009,7 +1007,7 @@ fn get_mem_as_value(matches: &clap::ArgMatches<'static>, config: &Config) -> boo false } -fn get_is_default_tree(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_is_default_tree(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("tree") { return true; } else if let Some(flags) = &config.flags { @@ -1020,7 +1018,7 @@ fn get_is_default_tree(matches: &clap::ArgMatches<'static>, config: &Config) -> false } -fn get_show_table_scroll_position(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_show_table_scroll_position(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("show_table_scroll_position") { return true; } else if let Some(flags) = &config.flags { @@ -1031,7 +1029,7 @@ fn get_show_table_scroll_position(matches: &clap::ArgMatches<'static>, config: & false } -fn get_is_default_process_command(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_is_default_process_command(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("process_command") { return true; } else if let Some(flags) = &config.flags { @@ -1042,7 +1040,7 @@ fn get_is_default_process_command(matches: &clap::ArgMatches<'static>, config: & false } -fn get_is_advanced_kill_disabled(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_is_advanced_kill_disabled(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("disable_advanced_kill") { return true; } else if let Some(flags) = &config.flags { @@ -1053,7 +1051,7 @@ fn get_is_advanced_kill_disabled(matches: &clap::ArgMatches<'static>, config: &C false } -fn get_network_unit_type(matches: &clap::ArgMatches<'static>, config: &Config) -> DataUnit { +fn get_network_unit_type(matches: &clap::ArgMatches, config: &Config) -> DataUnit { if matches.is_present("network_use_bytes") { return DataUnit::Byte; } else if let Some(flags) = &config.flags { @@ -1067,7 +1065,7 @@ fn get_network_unit_type(matches: &clap::ArgMatches<'static>, config: &Config) - DataUnit::Bit } -fn get_network_scale_type(matches: &clap::ArgMatches<'static>, config: &Config) -> AxisScaling { +fn get_network_scale_type(matches: &clap::ArgMatches, config: &Config) -> AxisScaling { if matches.is_present("network_use_log") { return AxisScaling::Log; } else if let Some(flags) = &config.flags { @@ -1081,7 +1079,7 @@ fn get_network_scale_type(matches: &clap::ArgMatches<'static>, config: &Config) AxisScaling::Linear } -fn get_network_use_binary_prefix(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { +fn get_network_use_binary_prefix(matches: &clap::ArgMatches, config: &Config) -> bool { if matches.is_present("network_use_binary_prefix") { return true; } else if let Some(flags) = &config.flags { |