cwim icon indicating copy to clipboard operation
cwim copied to clipboard

cwim - Count number of words in a markdown file / markdown files. CJK friendly.

icon

cwim

🎰 cwim - Count Words Inside a Markdown file. (CJK friendly)

GitHub

Welcome

c • wim /c-wɪm/

cwim - Count Words Inside a Markdown file. (CJK friendly) 0.1.0

USAGE:
    cwim [FLAGS] <FILE_OR_PATH>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
    -v, --verbose    Verbose mode (-v, -vv, etc.)

ARGS:
    <FILE_OR_PATH>    Target file or target directory

cwim is a command line tool for counting words inside a markdown file / markdown files. Written in pure Rust, cwim is fast, minimal and is compatible with almost any Unicode text segmentation. cwim is built attempting to mimic the functionalities of cloc - Count lines of code.

Note: I wrote this to study Rust in the first place, meaning cwim has not been proven to be production-ready.

Usage

We can run cwim against a single Markdown file:

cwim <MARKDOWN_FILE_NAME>.md # .mdown || .markdown

We can also feed cwim a folder / directory path:

cwim <DIRECTORY_PATH>

cwim is fast even when counting many files:

cwim <LARGE_DIRECTORY_WITH_MARKDOWN_FILES>

Run cwim -h for more information:

cwim -h

Installation

Grab the latest version of OS-specific cwim here: cwim - Releases

Then give the downloaded executable permissions to run, and move the executable to $PATH:

# Give sufficient permissions
sudo chmod +x cwim

# Move to $PATH
sudo mv cwim /usr/bin

Development

You'll need to install Rust on your local machine first, that includes rustc, cargo and other necessary toolkits. Then:

  • Build project:
cargo build
  • Run cwim:
cargo run
  • Run cwim with command line arguments:
cargo run -- <ARGS>

How does cwim work?

cwim first removes whitespace / blank lines / special characters / links / file urls and other word-irrelevant characters out of the Markdown file, then it uses the library unicode-segmentation to split text into Unicode words, then counts the words based on the list returned.

For more information:

  • Run the following command to show individual file listings:
cwim <FILE_OR_PATH> -v
  • Run the following command to see how the words are separated:
cwim <FILE_OR_PATH> -vv

🎰 cwim ©Spencer Woo. Released under the MIT License.

Authored and maintained by Spencer Woo.

@Portfolio · @Blog · @GitHub