Skip to main content

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) → uses len(text)

Main Entry Point

main() coordinates:

  1. Argument parsing
  2. File processing
  3. 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

saultcollege_csd110_25f_linewise-0.1.3.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file saultcollege_csd110_25f_linewise-0.1.3.tar.gz.

File metadata

File hashes

Hashes for saultcollege_csd110_25f_linewise-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2384d44103aaae7f22986cc083cfd4dbba5cf3ca9f5449d59e6d8a3c06abed1f
MD5 43ed1cfe127f44946ba70baaff47670a
BLAKE2b-256 cf4144b449c11c41e5fd5ce170f7b5484662244fe92554bca976ce2c488cc54b

See more details on using hashes here.

File details

Details for the file saultcollege_csd110_25f_linewise-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for saultcollege_csd110_25f_linewise-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6585e9c7ce3a68c1189ec3fdf5b0e577f7510340f69c32ff0e56daecb79d66ed
MD5 bf7d63c0c2035acc626a056e55458826
BLAKE2b-256 a586f27f2928fd11380b921a60b13418f5bd04285d4ecee2a9f94ac9fe4414e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page