ccwc replicates a subset of the functionality of the utility wc. This originated from a coding challenge which is available here.
Functionality includes counts of:
- Bytes
- Lines
- Words
- Characters
A text stream can also be piped to stdin of ccwc.
Ensure that Git and Python are installed, then run:
git clone [email protected]:parradam/ccwc.gitTo install dependencies, run:
pip install requirements.txtNavigate to the root of the repository, then run:
python main.py .gitignoreThis should yield 4 5 45 .gitignore.
Running python main.py -h yields:
positional arguments:
filename the filename to be checked
optional arguments:
-h, --help show this help message and exit
-c, --byte count the number of bytes
-l, --line count the number of lines
-w, --word count the number of words
-m, --char count the number of characters
ccwc will run the equivalent of -lwc, returning the line, word, and byte counts, as well as the filename.
python main.py test.txt
> 7145 58164 342190 test.txtAny combination of flags can be used, but note that the order will always be as specified in the Running ccwc section.
python main.py -l test.txt
> 7145 test.txtA text stream can also be piped to stdin of ccwc.
Note that no filename is displayed in the output, as the input to ccwc was not a file.
cat test.txt | python main.py
> 7145 58164 342190Optional arguments can also be used.
cat test.txt | python main.py -l
> 7145To start the unit tests, run:
python -m unittestmypy is used for type hinting. To check a file, run:
mypy main.pyYou may wish to alias this to ccwc.
- Adam Parr - parradam
Refer to LICENSE for details.
- Coding Challenges
- PurpleBooth for the original version of the README template