wc-tool

module
v0.0.0-...-270cc71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2023 License: MIT

README

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

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL