docs(readme): document --preserve-lines flag and indentation safety

This commit is contained in:
carraes
2025-07-06 11:21:24 -03:00
parent 70a2dd7612
commit d4295b4329
+29 -5
View File
@@ -38,6 +38,9 @@ shush script.sh --dry-run
# Create a backup before modifying # Create a backup before modifying
shush config.lua --backup shush config.lua --backup
# Keep comment-only lines as empty lines (indentation always preserved)
shush script.py --preserve-lines
# Verbose output # Verbose output
shush app.go --verbose shush app.go --verbose
@@ -80,10 +83,11 @@ shush src/ --recursive --inline --dry-run --verbose
--block Remove only block comments --block Remove only block comments
# Processing modes # Processing modes
-r, --recursive Process directories recursively -r, --recursive Process directories recursively
--dry-run Show what would be removed without making changes --dry-run Show what would be removed without making changes
--backup Create backup files before modification --backup Create backup files before modification
--verbose Show detailed output --verbose Show detailed output
--preserve-lines Keep comment-only lines as empty lines (indentation always preserved)
# Git-aware flags # Git-aware flags
--changes-only Remove comments only from git changes (staged + unstaged + untracked) --changes-only Remove comments only from git changes (staged + unstaged + untracked)
@@ -114,11 +118,19 @@ shush src/ --recursive --inline --dry-run --verbose
# Before # Before
# This is a comment # This is a comment
def hello(): def hello():
# Comment-only line
print("Hello") # Inline comment print("Hello") # Inline comment
# After running: shush example.py # After running: shush example.py (default - comment-only lines deleted)
def hello(): def hello():
print("Hello") print("Hello")
# After running: shush example.py --preserve-lines (comment-only lines kept as empty)
def hello():
print("Hello")
# Note: Code indentation is ALWAYS preserved in both modes
``` ```
### JavaScript ### JavaScript
@@ -158,6 +170,18 @@ shush --staged # 2. Clean staged changes
git commit -m "Clean code" # 3. Commit cleaned code git commit -m "Clean code" # 3. Commit cleaned code
``` ```
### Line Structure Control
```bash
# Default: Comment-only lines are deleted entirely
shush script.py # Clean removal
# Keep comment-only lines as empty lines (preserves line numbers)
shush script.py --preserve-lines # Useful for debugging/line references
# Code indentation is ALWAYS preserved regardless of flag
shush python_code.py --preserve-lines --dry-run
```
### Backup and Preview ### Backup and Preview
```bash ```bash
# Always create backup before modifying # Always create backup before modifying