rgon 0.2.0

A command-line tool written in Rust that searches for a query string within a file, similar to the grep command in Unix-like systems.
Documentation
  • Coverage
  • 0%
    0 out of 4 items documented0 out of 4 items with examples
  • Size
  • Source code size: 188.7 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 245.41 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jmeq17
rgon-0.2.0 has been yanked.

rgon - A simple Rust-based grep clone

rgon is a command-line tool written in Rust that searches for a query string within a file, similar to the grep command in Unix-like systems. It supports case-insensitive searching if an environment variable is set.

Features

  • Search for a query string in a text file.
  • Case-insensitive search if the IGNORE_CASE environment variable is set.
  • Prints matching lines from the file.

Installation

To use rgon, you'll need to have Rust and Cargo installed. If you don't have them, you can install them from https://rust-lang.org.

To install and run rgon, clone the repository and build the project:

git clone https://github.com/jmeq17/rgon.git

cd rgon

cargo build --release

Usage

Once installed, you can use rgon by running the following command:

cargo run <query> <file_path>

Example

cargo run "to" "assets/tinyTale.txt"

This will search for the string "to" in the file assets/tinyTale.txt and print all matching lines.

Case-Insensitive Search

To perform a case-insensitive search, set the IGNORE_CASE environment variable:

IGNORE_CASE=1 cargo run "To" "assets/tinyTale.txt"

This will match both "To" and "to" in the file.

Code Structure

  • Config struct: Holds the query string, file path, and case-insensitive flag.
  • run function: Executes the search based on the provided configuration.
  • search function: Searches for a query in the contents of a file.
  • search_case_insensitive function: Searches for a query in the contents of a file, ignoring case.
  • Tests: Includes unit tests for both case-sensitive and case-insensitive search functions.

Tests

To run the tests:

cargo test

This will run the unit tests for search and search_case_insensitive functions.

License

This project is licensed under the MIT License - see the LICENSE file for details.