Skip to main content

Senior-grade Python CLI to convert text between identifier cases.

Project description

text-case

Senior-grade Python CLI for converting text between identifier cases.

text-case converts a string between ten identifier cases — snake_case, camelCase, PascalCase, kebab-case, SCREAMING_SNAKE_CASE, Title Case, dot.case, flatcase, Train-Case, COBOL-CASE — accepting input as a CLI argument or via stdin. It detects word boundaries from any input format (camelCase, PascalCase, snake_case, kebab-case, SCREAMING_SNAKE_CASE, space-separated, or any mix).

Install

pip install text-case

Local development:

git clone https://github.com/brunoraniere2003/project-factory.git
cd project-factory/projects/text-case
python3.12 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

Usage

$ textcase to-snake "Hello World"
hello_world

$ textcase to-camel "hello world"
helloWorld

$ textcase to-pascal "hello world"
HelloWorld

$ textcase to-kebab "Hello World"
hello-world

$ textcase to-screaming "hello world"
HELLO_WORLD

$ textcase to-title "hello_world"
Hello World

$ textcase to-flat "Hello World"
helloworld

$ textcase to-train "hello_world"
Hello-World

$ textcase to-cobol "hello_world"
HELLO-WORLD

Stdin support

# implicit (omit the argument entirely)
$ echo "helloWorld" | textcase to-snake
hello_world

# explicit sentinel (POSIX convention)
$ echo "helloWorld" | textcase to-snake -
hello_world

Cross-format conversion

text-case detects word boundaries from any input format:

$ textcase to-snake "helloWorld"
hello_world

$ textcase to-camel "HELLO_WORLD"
helloWorld

$ textcase to-pascal "hello-world_test case"
HelloWorldTestCase

Edge cases

  • Idempotent: converting input that is already in the target format is a no-op.
  • Unicode preserved: Latin-1 characters (e.g., Olá, Á) round-trip correctly.
  • Empty input: rejected with a non-zero exit code.
  • - sentinel: passing - as the TEXT argument reads from piped stdin (POSIX convention); exits non-zero on an interactive TTY or empty pipe.

Development

# Run tests + coverage (must be 100%)
pytest

# Lint + format-check + type-check
ruff check .
black --check .
mypy --strict src

# All-in-one
pre-commit run --all-files

Architecture

See docs/adr/0001-typer-and-pytest.md for design rationale.

Three-layer module:

text_case/
├── __init__.py        # Public API (re-exports `convert`)
├── converter.py       # Pure functions: case conversions
└── cli.py             # Typer-based CLI (thin wrapper)

Methodology

Built by the Project Factory AI team following a 15-step methodology cycle on every change. See CLAUDE.md at the factory root.

  • 🗂️ Voyager (PM) — spec
  • 🧠 Apollo (TL) — design + review
  • 🌿💻♻️📚 Falcon (ENG) — branch, implement, refactor, document
  • 🧪 Hubble (QA) — failing tests first (RED)
  • 🚀 Atlas (DevOps) — ship

License

MIT

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

racdev_textcase-0.9.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

racdev_textcase-0.9.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file racdev_textcase-0.9.0.tar.gz.

File metadata

  • Download URL: racdev_textcase-0.9.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for racdev_textcase-0.9.0.tar.gz
Algorithm Hash digest
SHA256 79ded399c082d6a5d427429087fbaa2d6a6b75e2731402adb4408ff6ac8b5bc9
MD5 0502f97ebb4b618c7e79274945b473b4
BLAKE2b-256 da018b762df16f69515ac8b3e27ddbc1abb11aa4b6fb17a381b8e1868edab0fe

See more details on using hashes here.

File details

Details for the file racdev_textcase-0.9.0-py3-none-any.whl.

File metadata

File hashes

Hashes for racdev_textcase-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da7be9de2bd437d3b68cb571dbe59ae26f0b9545df0804c3e27923b101e2402e
MD5 03343ffcdce0ad6b08a8b8a54824b4fc
BLAKE2b-256 e6766592923a85262a252228fc798ff94bf190d3e9d4f50721abd17c11912445

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