Skip to content

Commit

Permalink
Added flag functionality, made case insensitive default from now on
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementTsang committed Feb 3, 2020
1 parent 6551885 commit 616ba01
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Run using `btm`.

- `-g`, `--group` will group together processes with the same name by default (equivalent to pressing `Tab`).

- `-i`, `--case_insensitive` will default to not matching case.
- `-s`, `--case_sensitive` will default to matching case.

- `-w`, `--whole` will default to searching for the world word.

Expand Down
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Default for AppSearchState {
AppSearchState {
current_search_query: String::default(),
searching_pid: false,
ignore_case: false,
ignore_case: true,
current_regex: BASE_REGEX.clone(),
current_cursor_position: 0,
match_word: false,
Expand Down
12 changes: 10 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn main() -> error::Result<()> {
//(@arg CONFIG_LOCATION: -co --config +takes_value "Sets the location of the config file. Expects a config file in the JSON format.")
//(@arg BASIC_MODE: -b --basic "Sets bottom to basic mode, not showing graphs and only showing basic tables.")
(@arg GROUP_PROCESSES: -g --group "Groups processes with the same name together on launch.")
(@arg CASE_INSENSITIVE: -i --case_insensitive "Do not match case when searching by default.")
(@arg CASE_SENSITIVE: -s --case_sensitive "Match case when searching by default.")
(@arg WHOLE_WORD: -w --whole "Match whole word when searching by default.")
(@arg REGEX_DEFAULT: -x --regex "Use regex in searching by default.")
)
Expand Down Expand Up @@ -134,10 +134,18 @@ fn main() -> error::Result<()> {
}

// Set default search method
if matches.is_present("CASE_INSENSITIVE") {
if matches.is_present("CASE_SENSITIVE") {
app.search_state.toggle_ignore_case();
}

if matches.is_present("WHOLE_WORD") {
app.search_state.toggle_search_whole_word();
}

if matches.is_present("REGEX_DEFAULT") {
app.search_state.toggle_search_regex();
}

// Set up up tui and crossterm
let mut stdout_val = stdout();
enable_raw_mode()?;
Expand Down

0 comments on commit 616ba01

Please sign in to comment.