commit 51cdd1d3585e4c928ad7ac5ef7aba6beeab53d9a Author: Samuele Iacoponi Date: Sun Mar 8 17:24:01 2026 +0100 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..1511dd5 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "minigrep" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..b8302ae --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "minigrep" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/README.md b/README.md new file mode 100644 index 0000000..de6a072 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# minigrep + +A command-line search tool built in Rust, following the [minigrep project](https://doc.rust-lang.org/book/ch12-00-an-io-project.html) from **The Rust Programming Language** book. + +## Usage + +```bash +cargo run -- +``` + +## What it does + +Searches for a string pattern within a file and prints the matching lines to stdout. + +## Purpose + +This is my personal implementation of the minigrep project from the Rust Book, used to practice Rust fundamentals such as: + +- CLI argument handling +- File I/O +- Error handling +- Structs and methods +- Iterators and closures +- Writing tests diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..b0b38db --- /dev/null +++ b/src/main.rs @@ -0,0 +1,15 @@ +use std::env; + +fn main() { + // Args returns an iterator of args from cli + // Collect turns an iterator into a collection + // In this case transform values of args into a vector + let args: Vec = env::args().collect(); + let query = &args[0]; + let file_path = &args[1]; + + println!("Searching for {query}"); + println!("In file {file_path}"); + // TODO handle the case of less or more parameters entered by user +} +