diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2020-12-28 14:34:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-28 14:34:32 -0500 |
commit | 60d0117c85e2e2f3d3072f767832a74093c496c1 (patch) | |
tree | 35ad77777f3dc9d353d6a4f5edaf8d364359c169 /src | |
parent | 30b2c2ea051d3c837edf82d595bf24a475da1431 (diff) |
feature: Add process_command to default to the process command (#379)
Adds a `process_command` flag and config option to default to showing the full command in the process widget on startup.
Diffstat (limited to 'src')
-rw-r--r-- | src/app/states.rs | 4 | ||||
-rw-r--r-- | src/clap.rs | 33 | ||||
-rw-r--r-- | src/constants.rs | 4 | ||||
-rw-r--r-- | src/options.rs | 16 |
4 files changed, 43 insertions, 14 deletions
diff --git a/src/app/states.rs b/src/app/states.rs index fe32a50d..d30adcc4 100644 --- a/src/app/states.rs +++ b/src/app/states.rs @@ -409,7 +409,7 @@ pub struct ProcWidgetState { impl ProcWidgetState { pub fn init( is_case_sensitive: bool, is_match_whole_word: bool, is_use_regex: bool, is_grouped: bool, - show_memory_as_values: bool, is_tree_mode: bool, + show_memory_as_values: bool, is_tree_mode: bool, is_using_command: bool, ) -> Self { let mut process_search_state = ProcessSearchState::default(); @@ -450,7 +450,7 @@ impl ProcWidgetState { scroll_state: AppScrollWidgetState::default(), process_sorting_type, is_process_sort_descending, - is_using_command: false, + is_using_command, current_column_index: 0, is_sort_open: false, columns, diff --git a/src/clap.rs b/src/clap.rs index 93d3acb8..323f0e5e 100644 --- a/src/clap.rs +++ b/src/clap.rs @@ -81,6 +81,15 @@ custom layouts.\n\n", "\ When searching for a process, enables case sensitivity by default.\n\n", ); + let current_usage = Arg::with_name("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", + ); // TODO: [DEBUG] Add a proper debugging solution. // let debug = Arg::with_name("debug") // .long("debug") @@ -106,7 +115,7 @@ Disables mouse clicks from interacting with the program.\n\n", Uses a dot marker for graphs as opposed to the default braille marker.\n\n", ); - let group = Arg::with_name("group") + let group = Arg::with_name("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.") @@ -136,12 +145,13 @@ Hides the spacing between table headers and entries.\n\n", "\ Completely hides the time scaling from being shown.\n\n", ); - let show_table_scroll_position = Arg::with_name("show_table_scroll_position") - .long("show_table_scroll_position") - .help("Shows the scroll position tracker in table widgets") + let process_command = Arg::with_name("process_command") + .long("process_command") + .help("Show processes as their commands by default.") .long_help( "\ - Shows the list scroll position tracker in the widget title for table widgets.\n\n", + Show processes as their commands by default in the process widget. + ", ); let left_legend = Arg::with_name("left_legend") .short("l") @@ -166,14 +176,12 @@ Puts the CPU chart legend to the left side rather than the right side.\n\n", "\ When searching for a process, enables regex by default.\n\n", ); - let current_usage = Arg::with_name("current_usage") - .short("u") - .long("current_usage") - .help("Sets process CPU% to be based on current CPU%.") + let show_table_scroll_position = Arg::with_name("show_table_scroll_position") + .long("show_table_scroll_position") + .help("Shows the scroll position tracker in table widgets.") .long_help( "\ -Sets process CPU% usage to be based on the current system CPU% usage -rather than total CPU usage.\n\n", + Shows the list scroll position tracker in the widget title for table widgets.\n\n", ); let use_old_network_legend = Arg::with_name("use_old_network_legend") .long("use_old_network_legend") @@ -277,7 +285,7 @@ use CPU (3) as the default instead. .long("default_widget_type") .takes_value(true) .value_name("WIDGET TYPE") - .help("Sets which widget type to use as the default widget.") + .help("Sets the default widget type, use --help for more info.") .long_help( "\ Sets which widget type to use as the default widget. @@ -361,6 +369,7 @@ Defaults to showing the process widget in tree mode.\n\n", .arg(basic) .arg(battery) .arg(case_sensitive) + .arg(process_command) .arg(config_location) .arg(color) // .arg(debug) diff --git a/src/constants.rs b/src/constants.rs index 0a6de6b1..8f44e427 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -398,6 +398,10 @@ pub const OLD_CONFIG_TEXT: &str = r##"# This is a default config file for bottom #mem_as_value = false # Show tree mode by default in the processes widget. #tree = false +# Shows an indicator in table widgets tracking where in the list you are. +#show_table_scroll_position = false +# Show processes as their commands by default in the process widget. +#process_command = false # These are all the components that support custom theming. Note that colour support # will depend on terminal support. diff --git a/src/options.rs b/src/options.rs index 9a8de130..8301094a 100644 --- a/src/options.rs +++ b/src/options.rs @@ -150,6 +150,9 @@ pub struct ConfigFlags { #[builder(default, setter(strip_option))] show_table_scroll_position: Option<bool>, + + #[builder(default, setter(strip_option))] + pub process_command: Option<bool>, } #[derive(Clone, Default, Debug, Deserialize, Serialize)] @@ -254,6 +257,7 @@ pub fn build_app( let show_memory_as_values = get_mem_as_value(matches, config); let is_default_tree = get_is_default_tree(matches, config); + let is_default_command = get_is_default_process_command(matches, config); for row in &widget_layout.rows { for col in &row.children { @@ -322,6 +326,7 @@ pub fn build_app( is_grouped, show_memory_as_values, is_default_tree, + is_default_command, ), ); } @@ -987,3 +992,14 @@ 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 { + if matches.is_present("process_command") { + return true; + } else if let Some(flags) = &config.flags { + if let Some(process_command) = flags.process_command { + return process_command; + } + } + false +} |