Code Monkey home page Code Monkey logo

mini_grep's Introduction

Mini-Grep

Overview

Project from "The Book", slightly modified.

Features

The application checks text by each new line. The terminal then returns output of the corresponding Query term and the line it resides on.

Running the project

Startup

    cargo install

Case Sensitive Search (Default)

    cargo run QUERY_TERM FILENAME.FILE_EXTENSION
  1. QUERY_TERM:

    • The query term is searched against all text within the specified file.
    • After the QUERY_TERM is found the program retruns a line with the specified text.
  2. FILENAME.FILE_EXTENSION

    • This is the file that is being queried against the QUERY_TERM.

Example of Case Sensitive Search

  • QUERY_TERM = foo

  • FILENAME.FILE_EXTENSION = foobar.txt

      "\
      Hello World!
      My name is foo bar,
      and I love programming."
  • Command:

      cargo run foo foobar.txt

The Terminal Output is: "My name is foo bar,"

Case Insensitive Search

Case Insensitive Search (C.I.S.) is similar to Case Sensitive Search (C.S.S.). Both of them use a QUERY_TERM and a FILENAME.FILE_EXTENSION as their Environment Arguments.

The difference between C.I.S. and C.S.S. is the addition of the optional argument "CASE_INSENSITIVE". The application checks whether or not it exists, and if it does then queries the text via Case Insensitivity.

Due to the varying ecosystems and the complexity of each systems API for env variables the way to do it for Windows is different then Linux/Mac.

Linux/Mac

The Terminal residing in Linux/Mac has a separate API for handling environment variables and has separate commands for interacting with the terminal.

    CASE_INSENSITIVE=1 cargo run QUERY_TERM FILENAME.FILE_EXTENSION

Windows

Windows allows you to set the environment variables via the set command.

SETTING ENV

This sets the environment variable in the OS and allows the program to perform C.I.S. .

    set CASE_INSENSITIVE=1

    cargo run QUERY_TERM FILENAME.FILE_EXTENSION

OR

    set CASE_INSENSITIVE=1 && cargo run QUERY_TERM FILENAME.FILE_EXTENSION
UNSET ENV

To unset the ENV variable set it with an empty value:

    set CASE_INSENSITIVE=

    cargo run QUERY_TERM FILENAME.FILE_EXTENSION

OR

    set CASE_INSENSITIVE= && cargo run QUERY_TERM FILENAME.FILE_EXTENSION

Dependencies

Only dependency necessary for this is ansi_term. This is used to colorize the output of the terminal.

mini_grep's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.