diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-12-20 21:51:39 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-12-20 21:51:39 +0100 |
| commit | 87ee550abea331430fc2db0f1d96d6acbfa6c8f2 (patch) | |
| tree | 96a6e126db498a2e5b562d9802651c62b630fe4b /rust-cli/grrs/src/main.rs | |
| download | learning-rust-87ee550abea331430fc2db0f1d96d6acbfa6c8f2.tar.xz learning-rust-87ee550abea331430fc2db0f1d96d6acbfa6c8f2.zip | |
$(date "+%D %T")
Diffstat (limited to 'rust-cli/grrs/src/main.rs')
| -rw-r--r-- | rust-cli/grrs/src/main.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/rust-cli/grrs/src/main.rs b/rust-cli/grrs/src/main.rs new file mode 100644 index 0000000..09e2d3a --- /dev/null +++ b/rust-cli/grrs/src/main.rs @@ -0,0 +1,21 @@ +use std::io::{BufReader, BufRead}; +use std::fs::File; +use::clap::Parser; + +#[derive(Parser)] +struct Cli { + pattern: String, + path: std::path::PathBuf, +} + + +fn main() { + let args = Cli::parse(); + //println!("pattern: {}, path: {}",args.pattern, args.path.display()); + let file = File::open(args.path).expect("could not read file"); + let mut reader = BufReader::new(file); + for line in reader.lines() { + if line.unwrap_or_default().contains(&args.pattern) { + } + } +} |
