{"id":27192374,"url":"https://github.com/sameh-farouk/rstgrep","last_synced_at":"2025-10-14T12:03:54.058Z","repository":{"id":127939576,"uuid":"370365800","full_name":"sameh-farouk/rstgrep","owner":"sameh-farouk","description":"a mini grep clone written in Rust","archived":false,"fork":false,"pushed_at":"2021-06-08T10:10:32.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T18:56:41.068Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sameh-farouk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-24T13:41:06.000Z","updated_at":"2021-06-08T10:10:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"4e10d304-36f7-4460-8e00-2470250693d3","html_url":"https://github.com/sameh-farouk/rstgrep","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/sameh-farouk/rstgrep","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sameh-farouk%2Frstgrep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sameh-farouk%2Frstgrep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sameh-farouk%2Frstgrep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sameh-farouk%2Frstgrep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sameh-farouk","download_url":"https://codeload.github.com/sameh-farouk/rstgrep/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sameh-farouk%2Frstgrep/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268240521,"owners_count":24218360,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-09T18:44:38.555Z","updated_at":"2025-10-14T12:03:49.005Z","avatar_url":"https://github.com/sameh-farouk.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![LinkedIn][linkedin-shield]][linkedin-url]\n\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003cdetails open=\"open\"\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\n      \u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#built-with\"\u003eBuilt With\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#prerequisites\"\u003ePrerequisites\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#examples\"\u003eExamples\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#acknowledgements\"\u003eAcknowledgements\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n## About The Project\nnote: this project for-educational-purposes-only.\n\nthis is a mini grep clone. That is a tool that we can give a string or regex pattern and a file path and it’ll print only the lines that contain the given string.\n\nwhile i code this project  I practiced the fundamentals and learnt about:\n* Parsing CLI arguments with `StructOpt`\n* using `BufReader` to read files contents.\n* handling Potential failure using a shortcut method on `Results`, called `unwrap`\n* use `anyhow` library to provide a context and build a custom error message and get a “chain” of error messages pointing out the root cause.\n* parsing, compiling, and executing regular expressions.\n\n### Built With\n\n* [Rust](https://www.rust-lang.org/)\n\n\n\u003c!-- GETTING STARTED --\u003e\n## Getting Started\n\nTo get a local copy up and running follow these simple example steps.\n\n### Prerequisites\n\n* Rust\n\nto install Rust run\n  ```sh\n  curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n  ```\nIf you have installed Rustup some time ago, chances are your Rust version is out of date. Get the latest version of Rust by running `rustup update`.\n\n### Installation\n\n1. Clone the repo\n   ```sh\n   git clone https://github.com/sameh-farouk/rstgrep.git\n   ```\n3. cd into `rstgrep`:\n   ```sh\n   cd rstgrep\n   ```\n4. Compile and run it in the same step using `cargo run` command:\n   ```sh\n   cargo run\n   ```\n\n\n\n\u003c!-- USAGE --\u003e\n## Usage\n\n### from src code\n\n`cargo run -- \u003cpattern\u003e \u003cpath\u003e`\n\n   ```sh\n   cargo run -- main ./src/main.rs\n   ```\n\nfor help you can run\n`cargo run -- --help`\n\n\n### from a release binary\n\nyou can downlaod the latest release from [here](https://github.com/sameh-farouk/rstgrep/releases) which built and tested on ubuntu 20.04\n\nor build it yourself from source code\n\n1. first to build the binary run `cargo build` command:\n   ```sh\n   cargo build --release\n   ```\n   you will find the built binary in `./target/release/`\n   ```sh\n   cd target/release/\n   ```\n\n2. run `./rstgrep \u003cpattern\u003e \u003cpath\u003e`\n:\n   ```sh\n   cd target/release\n   ./rstgrep main ../../src/main.rs\n   ```\n\nfor help you can run\n`./rstgrep --help`\n\n```\nrstGREP 0.2.0\nan alternative to grep written in Rust.\n\nUSAGE:\n    rstgrep [FLAGS] \u003cpattern\u003e \u003cpath\u003e\n\nFLAGS:\n    -c, --count          print only a count of selected lines per FILE\n    -h, --help           Prints help information\n    -n, --line-number    Show relative line number in the file\n    -r, --recursive      Read all files under each directory, recursively\n    -V, --version        Prints version information\n\nARGS:\n    \u003cpattern\u003e    The pattern to look for\n    \u003cpath\u003e       The path to the file to read\n```\n\nfinally, to be able to run rstgrep from any location without specifing the executable path, you could move or copy it to a location which exists in your PATH.\nfor example ```cp rstgrep ~/.local/bin/```\nalso you have to make sure that the rstgrep have executable permissions.\nwe can add execute permissions to the file (for everyone, perhaps) with ```chmod +x rstgrep```\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## Examples\nrstgrep regex syntax is similar to Perl-style regular expressions. you could do intersting things like find all lines with a date.\n\n```sh\nrstgrep -r \"\\d{4}-\\d{2}-\\d{2}\" testfile\n```\n\nThe syntax supported in rstgrep pattern is documented [here](https://docs.rs/regex/1.5.4/regex/#syntax)\n\n\u003c!-- ACKNOWLEDGEMENTS --\u003e\n## Acknowledgements\n* [The Rust Programming Language: The Book](https://doc.rust-lang.org/book/title-page.html)\n* [Command line apps in Rust](https://rust-cli.github.io/book/index.html)\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge\u0026logo=linkedin\u0026colorB=555\n[linkedin-url]: https://www.linkedin.com/in/sameh-farouk-software-developer/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsameh-farouk%2Frstgrep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsameh-farouk%2Frstgrep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsameh-farouk%2Frstgrep/lists"}