sit-counter
v1.0.2
Published
"CLI tool to count word occurrences in a file"
Readme
sit-counter-app 📊
A simple and fast CLI tool to count word occurrences in a text file.
You can either:
- get the count of all words, or
- search for the occurrence of a specific word
🚀 Installation
Install globally using npm:
npm install -g sit-counterMake sure Node.js (v18+) is installed on your system.
🧑💻 Usage
1️⃣ Count all words in a file
sit-counter-app <file-path>Example:
sit-counter-app file.txtOutput:
{
hello: 3,
world: 2,
node: 5
}2️⃣ Count a specific word
sit-counter-app <file-path> <word>Example:
sit-counter-app file.txt forOutput:
{
for: 3
}🔹 The search is case-insensitive
🛠 How It Works
- Reads the file using Node.js
fs/promises - Splits text using regex (
\W+) - Normalizes words to lowercase
- Uses an object to track word frequencies
- Accepts CLI arguments using
process.argv
📂 Example
sit-counter-app notes.txt javascriptResult:
{
javascript: 7
}⚠️ Error Handling
- If file path is missing → shows usage message
- If file does not exist → shows readable error
- Prevents app crash with try/catch
📦 Tech Stack
- Node.js
- ES Modules
- npm (CLI distribution)
👨💻 Author
Praduman Gupta Built for learning, experimenting, and flexing 💪
📄 License
NoLicense needed
---
