werds

Crates.iowerds
lib.rswerds
version1.0.0
sourcesrc
created_at2022-10-11 11:29:50.884058
updated_at2022-10-11 11:29:50.884058
descriptionDisplays the number of words in the specified file(s). Inspired by the wc Unix program.
homepage
repositoryhttps://github.com/brettchalupa/werds
max_upload_size
id685285
size23,289
Brett Chalupa (brettchalupa)

documentation

README

werds

A simple program that counts the number of words in the specified file(s).

Intention

A learning exercise in building a wc-esque program in Rust.

Attempts to follow the Command Line Interface Guidelines (clig) as best as possible.

Usage

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

Install

cargo install --git git@github.com:brettchalupa/werds.git

Developing

Test Runner

Use cargo watch (cargo install cargo-watch) to run the tests when files are changed:

cargo watch -x check -x test
Commit count: 35

cargo fmt