andrenbrandao / wc-tool

wc - Unix Command line tool built for John Crickett's Coding Challenge.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WC-Tool - Coding Challenge #1

This is my own version of the Unix command line tool wc. It is a solution to the first problem in John Crickett's Coding Challenges.

How to build

Execute make build to create the executable. It will be saved in the bin/ directory.

How to run

Execute the binary with a file as an argument to get the result.

The following are the possible arguments:

# Outputs the number of bytes

> ./bin/ccwc -c test.text
341836 test.txt

# Outputs the number of line breaks

> ./bin/ccwc -l test.text
7137 test.txt

# Outputs the number of characters

> ./bin/ccwc -m test.txt
339120 test.txt

# Outputs the number of words

> ./bin/ccwc -w test.text
58159 test.txt

# Outputs with -c, -l and -w flags
> ./bin/ccwc test.text
7137 58159 341836 test.txt

You can also read from standard input

> cat test.txt | ./bin/ccwc -l
7137

How to run the tests

Execute make test

You should see a result matching something like:

=== RUN   TestGetFileStats
--- PASS: TestGetFileStats (0.00s)
PASS
ok      github.com/andrenbrandao/wc-tool/cmd/ccwc       0.001s

License

MIT © André Brandão

About

wc - Unix Command line tool built for John Crickett's Coding Challenge.

License:MIT License


Languages

Language:Go 95.8%Language:Makefile 4.2%