Crates.io | werds |
lib.rs | werds |
version | 1.0.0 |
source | src |
created_at | 2022-10-11 11:29:50.884058 |
updated_at | 2022-10-11 11:29:50.884058 |
description | Displays the number of words in the specified file(s). Inspired by the wc Unix program. |
homepage | |
repository | https://github.com/brettchalupa/werds |
max_upload_size | |
id | 685285 |
size | 23,289 |
A simple program that counts the number of words in the specified file(s).
A learning exercise in building a wc
-esque program in Rust.
Attempts to follow the Command Line Interface Guidelines (clig) as best as possible.
A single file can be passed in:
$ werds path/to/file.md
22
Or pass in a collection of files:
$ werds tests/fixtures/*.txt
tests/fixtures/haiku.txt: 7
tests/fixtures/long.txt: 204
tests/fixtures/medium.txt: 8
total: 219
Or pipe in data from stdin with the -
file arg:
$ echo "Nothing quite like a fresh cup of tea\!" | werds -
8
stdin can be compiled with other files:
$ echo "hi there" | werds - README.md
stdin: 2
README.md: 124
total: 126
Or stdin can be used interactively with (with ^D to EOF):
$ werds -
Hi there
I just pased this in!
^D
7
The number of lines can also be counted instead of words with the -l
(short for --lines
) arg:
$ werds -l README.md
77
cargo install --git git@github.com:brettchalupa/werds.git
Use cargo watch
(cargo install cargo-watch
) to run the tests when files are changed:
cargo watch -x check -x test