https://github.com/tuanlc/word-count
https://github.com/tuanlc/word-count
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tuanlc/word-count
- Owner: tuanlc
- License: mit
- Created: 2024-02-24T08:01:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-25T13:00:37.000Z (over 1 year ago)
- Last Synced: 2025-01-02T14:38:17.174Z (5 months ago)
- Language: Go
- Size: 2.39 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Word count CLI in Go
[](https://opensource.org/licenses/MIT)
[](https://github.com/tuanlc/word-count/actions/workflows/ci.yml)
[](https://goreportcard.com/report/github.com/tuanlc/word-count)
[](https://pkg.go.dev/github.com/tuanlc/word-count)## Motivation
https://codingchallenges.fyi/challenges/challenge-wc
## Commands
### Development
- Run unit test
```bash
$ make test
```- Run build
```bash
$ make build
```- Clean folder
```bash
$ make clean
```### Usage
#### Directly usage
After building the tool successfully, there will be the executable file `ccwc` in the root folder.
- Count bytes
```bash
$ ./ccwc -c test.txt
342190 test.txt
```- Count lines
```bash
$ ./ccwc -l test.txt
7145 test.txt
```- Count words
```bash
$ ./ccwc -w test.txt
58164 test.txt
```- Count characters
```bash
$ ./ccwc -m test.txt
339292 test.txt
```- Count characters
```bash
$ ./ccwc test.txt
7145 58164 342190 test.txt
```#### Read from standar input
- Count bytes
```bash
$ cat test.txt | ./ccwc -c
342190 test.txt
```- Count lines
```bash
$ cat test.txt | ./ccwc -l
7145 test.txt
```- Count words
```bash
$ cat test.txt | ./ccwc -w
58164 test.txt
```- Count characters
```bash
$ cat test.txt | ./ccwc -m
339292 test.txt
```- Count characters
```bash
$ cat test.txt | ./ccwc
7145 58164 342190 test.txt
```## Testing
`ccwc` is a tool that tries to clone features from the [Unix command]() `wc`. Thus, the unit tests will use the output from `wc` as the source of truth. Moreover, the outcome of count words method could be different on different environments.
## License
[MIT](https://opensource.org/licenses/MIT)
Copyright (c) 2024-present, Tuan LE CONG