A command-line tool for counting lines, words, and characters.
Project description
Here is a shorter, clean, well-formatted, English README, ideal for PyPI:
linewise
linewise is a simple and safe command-line tool for analyzing text files.
It can count:
- Lines
- Words
- Characters
- Or all metrics at once
Installation
pip install linewise
Usage
linewise <file> [options]
Options
| Option | Description |
|---|---|
-h, --help |
Show help message |
--lines |
Count only lines |
--words |
Count only words |
--chars |
Count only characters |
If no option is provided, all metrics are returned.
Examples
linewise notes.txt --lines
linewise notes.txt --words
linewise notes.txt --chars
linewise notes.txt
Example output:
lines: 12
words: 85
chars: 451
How It Works
Argument Parsing
parse_args() validates:
- One file per command
- One metric flag at a time
- Valid flags only (
lines,words,chars)
Safe File Reading
linewise() reads the file with full error handling:
- File not found
- Directory instead of file
- Permission denied
- Invalid encoding
Counting Functions
All counting functions are pure:
count_lines(text)→ uses.splitlines()count_words(text)→ uses.split()count_char(text)→ useslen(text)
Main Entry Point
main() coordinates:
- Argument parsing
- File processing
- Formatted CLI output
Help Command
linewise --help
License
MIT (or your choice)
If you want, I can also generate a pyproject.toml, setup.cfg, and entry point configuration for PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file saultcollege_csd110_25f_linewise-0.1.3.tar.gz.
File metadata
- Download URL: saultcollege_csd110_25f_linewise-0.1.3.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.9 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2384d44103aaae7f22986cc083cfd4dbba5cf3ca9f5449d59e6d8a3c06abed1f
|
|
| MD5 |
43ed1cfe127f44946ba70baaff47670a
|
|
| BLAKE2b-256 |
cf4144b449c11c41e5fd5ce170f7b5484662244fe92554bca976ce2c488cc54b
|
File details
Details for the file saultcollege_csd110_25f_linewise-0.1.3-py3-none-any.whl.
File metadata
- Download URL: saultcollege_csd110_25f_linewise-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.9 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6585e9c7ce3a68c1189ec3fdf5b0e577f7510340f69c32ff0e56daecb79d66ed
|
|
| MD5 |
bf7d63c0c2035acc626a056e55458826
|
|
| BLAKE2b-256 |
a586f27f2928fd11380b921a60b13418f5bd04285d4ecee2a9f94ac9fe4414e0
|