# Comment Remover CLI
A high-accuracy Python tool for removing comments from programming files while preserving important code patterns such as color codes, URLs, and preprocessor directives.
## Features
- **Universal Language Support**: 20+ programming languages including Python, JavaScript, TypeScript, C/C++, Java, C#, Go, Rust, HTML, CSS, SQL, PHP, Ruby, and Shell scripts
- **Safe Operation**: Automatic backup creation before processing
- **Undo Capability**: Restore original files from backup
- **Configurable Settings**: JSON-based configuration system
- **Demo Mode**: Generate test files for validation
- **High Performance**: Efficient processing of entire directory trees
- **Recursive Scanning**: Processes all subdirectories automatically
- **Robust Error Handling**: Graceful handling of permission errors and encoding issues
## Installation
```bash
# Install via pip
pip install comment-remover-cli
# Or install from source
git clone https://github.com/guider23/Comms.git
cd Comms/comms_package
pip install .
```
## Usage
```bash
# Remove comments from current directory
python -m comms.cli
# Remove comments from specific directory
python -m comms.cli /path/to/your/project
# Create demo files for testing
python -m comms.cli --demo
# Restore files from backup
python -m comms.cli --undo
# Display help information
python -m comms.cli --help
```
## Command Line Options
```bash
python -m comms.cli [directory] [options]
Options:
-h, --help Show help message and exit
--demo Create demo files with comments for testing
--undo Restore files from most recent backup
--config FILE Use custom configuration file (default: config.json)
```
## Examples
### Processing Current Directory
```bash
python -m comms.cli
```
### Processing Specific Directory
```bash
python -m comms.cli /path/to/project
```
### Testing with Demo Files
```bash
python -m comms.cli --demo
python -m comms.cli demo_files/
```
## Configuration
Create a `config.json` file to customize behavior:
```json
{
"languages": {
"python": {
"extensions": [".py"],
"line_comment": "#",
"block_comment_start": "\"\"\"",
"block_comment_end": "\"\"\""
},
"javascript": {
"extensions": [".js", ".jsx"],
"line_comment": "//",
"block_comment_start": "/*",
"block_comment_end": "*/"
}
},
"backup_enabled": true,
"backup_directory": ".backup",
"skip_patterns": [
"node_modules/",
".git/",
"__pycache__/"
]
}
```
## Supported Languages
| Language | Extensions | Line Comments | Block Comments |
|----------|------------|---------------|----------------|
| Python | .py | # | """ """ or ''' ''' |
| JavaScript/TypeScript | .js, .jsx, .ts, .tsx | // | /* */ |
| Java | .java | // | /* */ |
| C/C++ | .c, .cpp, .h, .hpp | // | /* */ |
| C# | .cs | // | /* */ |
| Go | .go | // | /* */ |
| Rust | .rs | // | /* */ |
| PHP | .php | // | /* */ |
| Ruby | .rb | # | =begin =end |
| Shell/Bash | .sh, .bash | # | - |
| SQL | .sql | -- | /* */ |
| HTML | .html, .htm | - | <!-- --> |
| CSS | .css | - | /* */ |
| SCSS/Sass | .scss, .sass | // | /* */ |
| Lua | .lua | -- | --[[ ]] |
| Swift | .swift | // | /* */ |
| Kotlin | .kt, .kts | // | /* */ |
## Pattern Preservation
The tool intelligently preserves:
- **Color codes**: `#FF5733`, `#123ABC`
- **URLs**: `https://example.com`, `http://site.com`
- **Shebangs**: `#!/usr/bin/env python`
- **C Preprocessor**: `#include`, `#define`, `#if`, `#endif`, etc.
- **Content in strings**: Comments inside quoted strings remain untouched
## Example Usage
### Before Processing
**Python file:**
```python
#!/usr/bin/env python3
# This is a comment to remove
import requests # Another comment
def get_data():
"""This docstring stays"""
url = "https://api.example.com" # URL preserved
color = "#FF5733" # Color code preserved
# This comment will be removed
return requests.get(url)
```
### After Processing
**Python file:**
```python
#!/usr/bin/env python3
import requests
def get_data():
"""This docstring stays"""
url = "https://api.example.com"
color = "#FF5733"
return requests.get(url)
```
## Safety Features
### Automatic Backups
- All original files are backed up to `.backup/` directory
- Backup directory structure mirrors your project structure
- Previous backups are overwritten on each run
### Undo Operation
```bash
# Restore from most recent backup
python -m comms.cli --undo
```
### Pre-execution Warning
The tool displays:
- Number of files to be processed
- File types detected
- Clear warning about the operation
- Requires explicit confirmation
## Error Handling
- **Permission errors**: Gracefully skipped with warnings
- **Encoding issues**: Uses UTF-8 with error tolerance
- **Backup failures**: File processing is skipped if backup fails
- **Malformed files**: Processing continues with error reporting
## Advanced Usage
### Custom Configuration
```bash
python -m comms.cli --config custom-config.json /my/project
```
### Processing Specific File Types
Edit `config.json` to limit processing to specific languages or add new ones.
### Integration with Build Systems
```bash
# In your build script
python -m comms.cli src/ --config production-config.json
```
## Technical Details
### String Handling
- Properly handles escaped quotes in strings
- Supports single, double, and triple-quoted strings (Python)
- Preserves multiline strings and docstrings
### Comment Detection
- State-machine based parsing for accuracy
- Context-aware comment detection
- Handles nested comment structures
### Performance
- Processes files sequentially for reliability
- Memory-efficient line-by-line processing for large files
- Minimal I/O operations
## Requirements
- Python 3.6 or higher
- No external dependencies
- Cross-platform (Windows, macOS, Linux)
## Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Submit a pull request
## License
MIT License - see LICENSE file for details.
## Support
- **Issues**: Report bugs on [GitHub Issues](https://github.com/guider23/Comms/issues)
- **Documentation**: Full docs at [GitHub Repository](https://github.com/guider23/Comms)
## Why Comment Remover CLI?
- **Reliable**: Rule-based parsing, no heuristics
- **Fast**: Processes large codebases quickly
- **Safe**: Comprehensive backup system
- **Flexible**: Highly configurable
- **Maintained**: Active development and support
---
**Made for developers who value clean, production-ready code.**
Raw data
{
"_id": null,
"home_page": "https://github.com/guider23/Comms",
"name": "comment-remover-cli",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "comments removal programming development tools parsing",
"author": "guider23",
"author_email": "sofiyasenthilkumar@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/28/e3/7d720ab3e869d481406662e51bfa36fb2a109163f79cfe53309e8795e47f/comment_remover_cli-1.1.0.tar.gz",
"platform": null,
"description": "# Comment Remover CLI\r\n\r\nA high-accuracy Python tool for removing comments from programming files while preserving important code patterns such as color codes, URLs, and preprocessor directives.\r\n\r\n## Features\r\n\r\n- **Universal Language Support**: 20+ programming languages including Python, JavaScript, TypeScript, C/C++, Java, C#, Go, Rust, HTML, CSS, SQL, PHP, Ruby, and Shell scripts\r\n- **Safe Operation**: Automatic backup creation before processing\r\n- **Undo Capability**: Restore original files from backup\r\n- **Configurable Settings**: JSON-based configuration system\r\n- **Demo Mode**: Generate test files for validation\r\n- **High Performance**: Efficient processing of entire directory trees\r\n- **Recursive Scanning**: Processes all subdirectories automatically\r\n- **Robust Error Handling**: Graceful handling of permission errors and encoding issues\r\n\r\n## Installation\r\n\r\n```bash\r\n# Install via pip\r\npip install comment-remover-cli\r\n\r\n# Or install from source\r\ngit clone https://github.com/guider23/Comms.git\r\ncd Comms/comms_package\r\npip install .\r\n```\r\n\r\n## Usage\r\n\r\n```bash\r\n# Remove comments from current directory\r\npython -m comms.cli\r\n\r\n# Remove comments from specific directory\r\npython -m comms.cli /path/to/your/project\r\n\r\n# Create demo files for testing\r\npython -m comms.cli --demo\r\n\r\n# Restore files from backup\r\npython -m comms.cli --undo\r\n\r\n# Display help information\r\npython -m comms.cli --help\r\n```\r\n\r\n## Command Line Options\r\n\r\n```bash\r\npython -m comms.cli [directory] [options]\r\n\r\nOptions:\r\n -h, --help Show help message and exit\r\n --demo Create demo files with comments for testing\r\n --undo Restore files from most recent backup\r\n --config FILE Use custom configuration file (default: config.json)\r\n```\r\n\r\n## Examples\r\n\r\n### Processing Current Directory\r\n```bash\r\npython -m comms.cli\r\n```\r\n\r\n### Processing Specific Directory\r\n```bash\r\npython -m comms.cli /path/to/project\r\n```\r\n\r\n### Testing with Demo Files\r\n```bash\r\npython -m comms.cli --demo\r\npython -m comms.cli demo_files/\r\n```\r\n\r\n## Configuration\r\n\r\nCreate a `config.json` file to customize behavior:\r\n\r\n```json\r\n{\r\n \"languages\": {\r\n \"python\": {\r\n \"extensions\": [\".py\"],\r\n \"line_comment\": \"#\",\r\n \"block_comment_start\": \"\\\"\\\"\\\"\",\r\n \"block_comment_end\": \"\\\"\\\"\\\"\"\r\n },\r\n \"javascript\": {\r\n \"extensions\": [\".js\", \".jsx\"],\r\n \"line_comment\": \"//\",\r\n \"block_comment_start\": \"/*\",\r\n \"block_comment_end\": \"*/\"\r\n }\r\n },\r\n \"backup_enabled\": true,\r\n \"backup_directory\": \".backup\",\r\n \"skip_patterns\": [\r\n \"node_modules/\",\r\n \".git/\",\r\n \"__pycache__/\"\r\n ]\r\n}\r\n```\r\n\r\n## Supported Languages\r\n\r\n| Language | Extensions | Line Comments | Block Comments |\r\n|----------|------------|---------------|----------------|\r\n| Python | .py | # | \"\"\" \"\"\" or ''' ''' |\r\n| JavaScript/TypeScript | .js, .jsx, .ts, .tsx | // | /* */ |\r\n| Java | .java | // | /* */ |\r\n| C/C++ | .c, .cpp, .h, .hpp | // | /* */ |\r\n| C# | .cs | // | /* */ |\r\n| Go | .go | // | /* */ |\r\n| Rust | .rs | // | /* */ |\r\n| PHP | .php | // | /* */ |\r\n| Ruby | .rb | # | =begin =end |\r\n| Shell/Bash | .sh, .bash | # | - |\r\n| SQL | .sql | -- | /* */ |\r\n| HTML | .html, .htm | - | <!-- --> |\r\n| CSS | .css | - | /* */ |\r\n| SCSS/Sass | .scss, .sass | // | /* */ |\r\n| Lua | .lua | -- | --[[ ]] |\r\n| Swift | .swift | // | /* */ |\r\n| Kotlin | .kt, .kts | // | /* */ |\r\n\r\n## Pattern Preservation\r\n\r\nThe tool intelligently preserves:\r\n\r\n- **Color codes**: `#FF5733`, `#123ABC`\r\n- **URLs**: `https://example.com`, `http://site.com`\r\n- **Shebangs**: `#!/usr/bin/env python`\r\n- **C Preprocessor**: `#include`, `#define`, `#if`, `#endif`, etc.\r\n- **Content in strings**: Comments inside quoted strings remain untouched\r\n\r\n## Example Usage\r\n\r\n### Before Processing\r\n\r\n**Python file:**\r\n```python\r\n#!/usr/bin/env python3\r\n# This is a comment to remove\r\nimport requests # Another comment\r\n\r\ndef get_data():\r\n \"\"\"This docstring stays\"\"\"\r\n url = \"https://api.example.com\" # URL preserved\r\n color = \"#FF5733\" # Color code preserved\r\n # This comment will be removed\r\n return requests.get(url)\r\n```\r\n\r\n### After Processing\r\n\r\n**Python file:**\r\n```python\r\n#!/usr/bin/env python3\r\nimport requests\r\n\r\ndef get_data():\r\n \"\"\"This docstring stays\"\"\"\r\n url = \"https://api.example.com\"\r\n color = \"#FF5733\"\r\n return requests.get(url)\r\n```\r\n\r\n## Safety Features\r\n\r\n### Automatic Backups\r\n- All original files are backed up to `.backup/` directory\r\n- Backup directory structure mirrors your project structure\r\n- Previous backups are overwritten on each run\r\n\r\n### Undo Operation\r\n```bash\r\n# Restore from most recent backup\r\npython -m comms.cli --undo\r\n```\r\n\r\n### Pre-execution Warning\r\nThe tool displays:\r\n- Number of files to be processed\r\n- File types detected\r\n- Clear warning about the operation\r\n- Requires explicit confirmation\r\n\r\n## Error Handling\r\n\r\n- **Permission errors**: Gracefully skipped with warnings\r\n- **Encoding issues**: Uses UTF-8 with error tolerance\r\n- **Backup failures**: File processing is skipped if backup fails\r\n- **Malformed files**: Processing continues with error reporting\r\n\r\n## Advanced Usage\r\n\r\n### Custom Configuration\r\n```bash\r\npython -m comms.cli --config custom-config.json /my/project\r\n```\r\n\r\n### Processing Specific File Types\r\nEdit `config.json` to limit processing to specific languages or add new ones.\r\n\r\n### Integration with Build Systems\r\n```bash\r\n# In your build script\r\npython -m comms.cli src/ --config production-config.json\r\n```\r\n\r\n## Technical Details\r\n\r\n### String Handling\r\n- Properly handles escaped quotes in strings\r\n- Supports single, double, and triple-quoted strings (Python)\r\n- Preserves multiline strings and docstrings\r\n\r\n### Comment Detection\r\n- State-machine based parsing for accuracy\r\n- Context-aware comment detection\r\n- Handles nested comment structures\r\n\r\n### Performance\r\n- Processes files sequentially for reliability\r\n- Memory-efficient line-by-line processing for large files\r\n- Minimal I/O operations\r\n\r\n## Requirements\r\n\r\n- Python 3.6 or higher\r\n- No external dependencies\r\n- Cross-platform (Windows, macOS, Linux)\r\n\r\n## Contributing\r\n\r\n1. Fork the repository\r\n2. Create a feature branch\r\n3. Make your changes\r\n4. Add tests\r\n5. Submit a pull request\r\n\r\n## License\r\n\r\nMIT License - see LICENSE file for details.\r\n\r\n## Support\r\n\r\n- **Issues**: Report bugs on [GitHub Issues](https://github.com/guider23/Comms/issues)\r\n- **Documentation**: Full docs at [GitHub Repository](https://github.com/guider23/Comms)\r\n\r\n## Why Comment Remover CLI?\r\n\r\n- **Reliable**: Rule-based parsing, no heuristics\r\n- **Fast**: Processes large codebases quickly\r\n- **Safe**: Comprehensive backup system\r\n- **Flexible**: Highly configurable\r\n- **Maintained**: Active development and support\r\n\r\n---\r\n\r\n**Made for developers who value clean, production-ready code.**\r\n",
"bugtrack_url": null,
"license": null,
"summary": "High-accuracy comment removal tool for 20+ programming languages",
"version": "1.1.0",
"project_urls": {
"Bug Tracker": "https://github.com/guider23/Comms/issues",
"Documentation": "https://github.com/guider23/Comms#readme",
"Homepage": "https://github.com/guider23/Comms",
"Source Code": "https://github.com/guider23/Comms"
},
"split_keywords": [
"comments",
"removal",
"programming",
"development",
"tools",
"parsing"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "51d81d09aac6720839fc4a51fb2bf4eb71bfdde87893caa22ac89382cdbace0d",
"md5": "9711de03e0a2f27b8c894c5e039b9334",
"sha256": "edb58d4d0fd0cb457955f3b07acbb35d8e867c08fb64ff1dde0da4575db45f89"
},
"downloads": -1,
"filename": "comment_remover_cli-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9711de03e0a2f27b8c894c5e039b9334",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 16466,
"upload_time": "2025-08-03T12:28:11",
"upload_time_iso_8601": "2025-08-03T12:28:11.093805Z",
"url": "https://files.pythonhosted.org/packages/51/d8/1d09aac6720839fc4a51fb2bf4eb71bfdde87893caa22ac89382cdbace0d/comment_remover_cli-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "28e37d720ab3e869d481406662e51bfa36fb2a109163f79cfe53309e8795e47f",
"md5": "524729538888d907d9659c32c8db537b",
"sha256": "e49380444f15503284ffd852a8ace1c9ca09b1a52620572722bf12a6bda69565"
},
"downloads": -1,
"filename": "comment_remover_cli-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "524729538888d907d9659c32c8db537b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 14911,
"upload_time": "2025-08-03T12:28:12",
"upload_time_iso_8601": "2025-08-03T12:28:12.632083Z",
"url": "https://files.pythonhosted.org/packages/28/e3/7d720ab3e869d481406662e51bfa36fb2a109163f79cfe53309e8795e47f/comment_remover_cli-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-03 12:28:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "guider23",
"github_project": "Comms",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "comment-remover-cli"
}