Skip to content

fianso98/wc-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ccwc - Coding Challenges Word Count Tool

Overview

ccwc is a simple command-line tool written in TypeScript that mimics the behavior of the Unix wc command. It counts the number of lines, words, and characters in a given text input, either from files or through streams.

Features

  • Word Counting: Counts the number of words in the input.
  • Line Counting: Counts the number of lines in the input.
  • Character Counting: Counts the number of characters in the input.

Installation

Ensure that you have Node.js and npm installed on your machine.

  1. Clone this repository:
  2. git clone https://github.com/fianso98/wc-tool
  3. Navigate to the project directory:
  4. cd ccwc
  5. Install dependencies:
  6. npm install
  7. run default
  8. npm run start
    
  9. Make the script executable
  10. npm i -g pkg
    

    than go and modify package.json "executable" script to suits your device than run

    npm run exectuable
    

Usage

-c outputs the number of bytes in a file

ccwc -c test.txt

output > 342190 test.txt

-l outputs the number of lines in a file.

ccwc -l test.txt

output > 7145 test.txt

-w outputs the number of words in a file.

ccwc -w test.txt

output > 58164 test.txt

-m outputs the number of characters in a file.

ccwc -m test.txt

output > 339292 test.txt

no options are provided, which is the equivalent to the -c, -l and -w options

ccwc test.txt

output > 7145 58164 342190 test.txt

support being able to read from standard input if no filename is specified

cat test.txt | ccwc -l

output > 7145

Feedback

Feel free to open issues or submit pull requests if you have suggestions or improvements for ccwc. Your feedback is valuable!

Note on Executable Command

If you want to adjust the executable command in the package.json file to suit your machine, you can change it like this:

Copy code

"executable": "tsc && pkg dist/main.js --targets node18-macos-x64 --output ccwc"

Modify the --targets flag according to your Node.js version and operating system. For instance, if you are using Node.js version 14 on Windows, you might use --targets node14-win-x64. Adjust the --output flag if you want to change the output executable name. Make sure to refer to the pkg documentation for more details on available options.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published