Text Utils Examples
The text utils group provides commands for common text manipulation tasks.
Uppercase
Convert text to uppercase:
With clipboard support (requires pyperclip):
cli-utils local text-utils uppercase "hello world" --copy
# Output: HELLO WORLD
# ✓ Copied to clipboard
Lowercase
Convert text to lowercase:
Title Case
Convert text to title case:
Use Cases
Processing File Names
# Convert filename to lowercase
NEW_NAME=$(cli-utils local text-utils lowercase "MY_FILE.TXT")
mv "MY_FILE.TXT" "$NEW_NAME"
Formatting Output
Batch Processing
# Process multiple strings
for word in "hello" "world" "test"; do
cli-utils local text-utils titlecase "$word"
done
Adding More Text Utils
You can easily add more text utilities. Here's an example:
# src/cli_utils/commands/local/text_utils/reverse.py
import typer
from rich.console import Console
console = Console()
def reverse(
text: str = typer.Argument(..., help="Text to reverse"),
) -> None:
"""Reverse the input text."""
result = text[::-1]
console.print(f"[green]{result}[/green]")
Then use it: