The quotes-convert CLI provides a convenient way to convert quotes in files and streams directly from your terminal.
The CLI requires the typer dependency, which is installed as an optional extra:
pip install quotes-convert[cli]# Convert to single quotes
echo 'x = "hello"' | quotes-convert --single
# Convert to double quotes
echo "x = 'hello'" | quotes-convert --double
# Use short flags
quotes-convert -s file.py
quotes-convert -d file.py
# Check version
quotes-convert --versionquotes-convert [OPTIONS] [FILES]...
| Option | Short | Description |
|---|---|---|
--single |
-s |
Convert matching quotes to single quotes |
--double |
-d |
Convert matching quotes to double quotes |
--in-place |
-i |
Edit files in place (requires file arguments) |
--output PATH |
-o PATH |
Write output to specified file |
--version |
-V |
Show version and exit |
--help |
Show help message and exit |
| Argument | Description |
|---|---|
FILES |
Files to convert. If not provided, reads from stdin. |
Process text from stdin and output to stdout:
# From echo
echo 'name = "Alice"' | quotes-convert -s
# Output: name = 'Alice'
# From file via cat
cat script.py | quotes-convert -s
# Chain with other commands
cat data.txt | quotes-convert -s | grep "pattern"Preview changes before modifying files:
# Display converted content
quotes-convert -s myfile.py
# Check before applying
quotes-convert -s config.py | lessModify files directly:
# Single file
quotes-convert -s -i script.py
# Multiple files
quotes-convert -s -i file1.py file2.py file3.py
# Glob patterns (shell expansion)
quotes-convert -s -i src/*.py
quotes-convert -s -i *.pyWarning: In-place editing modifies files directly. Always use version control (git) or create backups before batch editing.
Save converted content to a new file:
# From stdin
echo 'x = "test"' | quotes-convert -s -o output.py
# From file
quotes-convert -s input.py -o output.py# Convert Python files to use single quotes
quotes-convert -s -i src/*.py tests/*.py
# Preview changes first
quotes-convert -s main.py > /tmp/preview.py
diff main.py /tmp/preview.py# Convert to double quotes
quotes-convert -d -i src/*.ts src/*.js# Convert all Python files in a directory tree
find . -name "*.py" -type f -exec quotes-convert -s -i {} \;
# With progress indicator
find . -name "*.py" -type f | while read f; do
echo "Processing: $f"
quotes-convert -s -i "$f"
done# Process 4 files at a time in parallel
find . -name "*.py" | xargs -P 4 -n 1 quotes-convert -s -i# Convert only staged Python files
git diff --cached --name-only | grep '\.py$' | xargs quotes-convert -s -i
# Convert files changed in current branch vs main
git diff --name-only main | grep '\.py$' | xargs quotes-convert -s -iAdd to your ~/.bashrc or ~/.zshrc:
alias sq='quotes-convert --single'
alias dq='quotes-convert --double'
alias sqi='quotes-convert --single --in-place'
alias dqi='quotes-convert --double --in-place'Usage:
sq file.py # preview
sqi file.py # in-place
echo 'x="y"' | sq # pipeThe CLI provides clear error messages for common issues:
$ quotes-convert file.py
Error: Must specify either --single or --double$ quotes-convert -s -d file.py
Error: Cannot specify both --single and --double
$ quotes-convert -s -i -o output.py file.py
Error: Cannot specify both --in-place and --output$ quotes-convert -s nonexistent.txt
Error: Invalid value for '[FILES]...': Path 'nonexistent.txt' does not exist.$ quotes-convert -s -i /root/protected.py
Error: Permission denied: /root/protected.py$ quotes-convert -s binary.dat
Error: Cannot decode file (not UTF-8): binary.datThe CLI uses streaming by default when not editing in-place, efficiently handling large files:
# Efficiently handles large files
quotes-convert -s huge_file.txt > output.txt- Streaming mode (default): Low memory, handles any file size
- In-place mode (
-i): Loads entire file into memory
For many files, use parallel processing:
# Process 4 files at a time
find . -name "*.py" | xargs -P 4 -n 1 quotes-convert -s -iIf quotes-convert command is not found:
# Ensure CLI extras are installed
pip install quotes-convert[cli]
# Verify installation
pip show quotes-convert
# Check if it's in PATH
which quotes-convert
# Alternative: run with python -m
python -m quotes_convert.cli --helpIf you get "CLI dependencies not installed":
# Reinstall with CLI extras
pip install --force-reinstall quotes-convert[cli]# Check version
quotes-convert --version
# Test with simple input
echo 'test = "value"' | quotes-convert -s- API Reference - Library API documentation
- Interactive Playground - Try it in your browser
- Contributing Guide - Help improve the CLI