diff --git a/Cargo.lock b/Cargo.lock index 92fff54..fc85822 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1422,6 +1422,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "300.3.1+3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7259953d42a81bf137fbbd73bd30a8e1914d6dce43c2b90ed575783a22608b91" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.102" @@ -1430,6 +1439,7 @@ checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -2604,7 +2614,7 @@ dependencies = [ [[package]] name = "webgrep" -version = "0.3.1" +version = "0.3.3" dependencies = [ "async-recursion", "clap", diff --git a/Cargo.toml b/Cargo.toml index 3dee0dd..10e0bb1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "webgrep" -version = "0.3.2" +version = "0.3.3" edition = "2021" license = "MIT" description = "grep the web: a full-browser-spec search-focused ultra-simple way to read the web without having to leave the terminal" diff --git a/src/main.rs b/src/main.rs index 965f0e4..b3808ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,11 @@ async fn main() { let num_urls = text_elements.keys().len(); let mut re = Regex::new(".*").unwrap(); if args.search.is_some() { - re = Regex::new(&args.search.unwrap()).unwrap(); + if args.insensitive.is_some() && args.insensitive.unwrap() == true { + re = Regex::new(&("(?i)".to_owned() + &args.search.unwrap())).unwrap(); + } else { + re = Regex::new(&args.search.unwrap()).unwrap(); + } } for (link, texts) in text_elements.into_iter() { let mut printed_texts: HashMap = HashMap::new(); diff --git a/src/structs/Args.rs b/src/structs/Args.rs index 7024a11..fb3e6a1 100644 --- a/src/structs/Args.rs +++ b/src/structs/Args.rs @@ -13,6 +13,9 @@ pub struct ArgParser { #[arg(short, long)] pub recursive: Option, + #[arg(short, long, action=ArgAction::SetTrue)] + pub insensitive: Option, + #[arg(short = 'o', long = "samehost", action=ArgAction::SetTrue)] pub samehost: Option, diff --git a/tests/test_cases.toml b/tests/test_cases.toml index 3a5acf7..697443a 100644 --- a/tests/test_cases.toml +++ b/tests/test_cases.toml @@ -57,3 +57,9 @@ name = "Search/Basic" run_type = "output" cmd = "../target/release/webgrep https://quinnpatwardhan.com/aboutme Ravens -c" expect = "die-hard" + +[[test_cases]] +name = "Search/Insensitive" +run_type = "lines_count" +cmd = "../target/release/webgrep https://google.com dark -i" +expect = "3"