From 77a88c99b942eb7a5d8329173e0f59b24182f350 Mon Sep 17 00:00:00 2001 From: Benji Nguyen <45523555+solidiquis@users.noreply.github.com> Date: Sun, 12 Jan 2025 19:03:20 -0800 Subject: [PATCH] docs: readme update (#9) --- README.md | 21 +++++++++++---------- images/demo.png | Bin 1183189 -> 803818 bytes 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ba46b4a..dc076c4 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,21 @@ [![Crates.io](https://img.shields.io/crates/v/grits.svg)](https://crates.io/crates/grits) [![Crates.io](https://img.shields.io/crates/d/grits)](https://crates.io/crates/grits) -`grits` is a minimal, simple, easy-to-use line text-processor that applies regular expressions with named captures to input lines +`grits` is a minimal, simple, and easy-to-use line text-processor that applies regular expressions with named captures to input lines and transforms them using a custom template string. It allows for efficient parsing, extracting, and formatting of text, including support for colorization and other attributes you'd get using ANSI escape sequences. -The following example demonstrates how to apply `grits` to `tcpdump` to extract a packet's source IP address: +The following example demonstrates how to apply `grits` to `tcpdump` to extract a packet's source (`src`) and destination (`dst`) IP address: ```bash -tcpdump | grits -p '^(?[^ ]+)' \ +sudo tcpdump -nn | grits -p '^(?[^ ]+)' \ -p 'IP\w? (?[^ ]+)' \ - -t '[${(cyan|bold):ts}] ${(green|underlined):"src"}=${src || "NOMATCH"}' - + -p '> (?[^ ]+):' \ + -t '[${(cyan|bold):ts}] ${(green|underlined):"src"}=${src} ${(yellow|underlined):"dst"}=${dst}' ``` ![demo image](images/demo.png) -The left pane in the above screenshot is the raw output of `tcpdump` while the right pane shows the output being piped into `grits`. +The top pane in the above screenshot is the raw output of `tcpdump` while the bottom pane shows the output being piped into `grits`. ## Table of Contents @@ -49,7 +49,8 @@ Arguments: Options: -p, --pattern A regular expression with named captures. Can be specified multiple times -t, --template