# Comment Remover CLI
[](https://badge.fury.io/py/comment-remover-cli)
[](https://pypi.org/project/comment-remover-cli/)
[](https://opensource.org/licenses/MIT)
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
### From PyPI (Recommended)
```bash
pip install comment-remover-cli
```
### From Source
```bash
git clone https://github.com/guider23/Comms.git
cd Comms
pip install .
```
## Quick Start
```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)
```
## 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)
```
## 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__/"
]
}
```
## 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
We welcome contributions! Please follow these steps:
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
### Development Setup
```bash
git clone https://github.com/guider23/Comms.git
cd Comms
pip install -e .
```
### Running Tests
```bash
python -m pytest tests/
```
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Support
- **Issues**: Report bugs on [GitHub Issues](https://github.com/guider23/Comms/issues)
- **PyPI Package**: [comment-remover-cli](https://pypi.org/project/comment-remover-cli/)
- **Documentation**: Full docs at [GitHub Repository](https://github.com/guider23/Comms)
## Changelog
### v1.1.0
- Professional documentation
- Improved error handling
- Enhanced pattern preservation
- Updated PyPI package
### v1.0.0
- Initial release
- Support for 20+ programming languages
- Automatic backup and undo functionality
- Configurable settings
---
**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/e8/65/40a9b6e1c2c7a53968c4ac35067bc8692234f5287749a93f02c13bb9e6cb/comment_remover_cli-1.2.1.tar.gz",
"platform": null,
"description": "# Comment Remover CLI\r\n\r\n[](https://badge.fury.io/py/comment-remover-cli)\r\n[](https://pypi.org/project/comment-remover-cli/)\r\n[](https://opensource.org/licenses/MIT)\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### From PyPI (Recommended)\r\n```bash\r\npip install comment-remover-cli\r\n```\r\n\r\n### From Source\r\n```bash\r\ngit clone https://github.com/guider23/Comms.git\r\ncd Comms\r\npip install .\r\n```\r\n\r\n## Quick Start\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## 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## 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## 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\nWe welcome contributions! Please follow these steps:\r\n\r\n1. Fork the repository\r\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\r\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\r\n4. Push to the branch (`git push origin feature/amazing-feature`)\r\n5. Open a Pull Request\r\n\r\n### Development Setup\r\n\r\n```bash\r\ngit clone https://github.com/guider23/Comms.git\r\ncd Comms\r\npip install -e .\r\n```\r\n\r\n### Running Tests\r\n\r\n```bash\r\npython -m pytest tests/\r\n```\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](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- **PyPI Package**: [comment-remover-cli](https://pypi.org/project/comment-remover-cli/)\r\n- **Documentation**: Full docs at [GitHub Repository](https://github.com/guider23/Comms)\r\n\r\n## Changelog\r\n\r\n### v1.1.0\r\n- Professional documentation\r\n- Improved error handling\r\n- Enhanced pattern preservation\r\n- Updated PyPI package\r\n\r\n### v1.0.0\r\n- Initial release\r\n- Support for 20+ programming languages\r\n- Automatic backup and undo functionality\r\n- Configurable settings\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 with beautiful CLI",
"version": "1.2.1",
"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": "524c95f2e53fa1d645674652adaa9b2388be58050e315454425a1ac424a9efde",
"md5": "30134bb2758e7dcf6fd58a8d460bf9cf",
"sha256": "0b13aa02f504fb4bdb452a9eedbd3f7052c783b445012ffedae249b69a36ff36"
},
"downloads": -1,
"filename": "comment_remover_cli-1.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "30134bb2758e7dcf6fd58a8d460bf9cf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 19354,
"upload_time": "2025-08-04T14:04:45",
"upload_time_iso_8601": "2025-08-04T14:04:45.652152Z",
"url": "https://files.pythonhosted.org/packages/52/4c/95f2e53fa1d645674652adaa9b2388be58050e315454425a1ac424a9efde/comment_remover_cli-1.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "e86540a9b6e1c2c7a53968c4ac35067bc8692234f5287749a93f02c13bb9e6cb",
"md5": "8b3416005e47aaad5554bf6288c1b9c6",
"sha256": "0dba11d6998b728175c95e35fbba933b64b68e178536c3cbb64aea4d28e57565"
},
"downloads": -1,
"filename": "comment_remover_cli-1.2.1.tar.gz",
"has_sig": false,
"md5_digest": "8b3416005e47aaad5554bf6288c1b9c6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 17415,
"upload_time": "2025-08-04T14:04:48",
"upload_time_iso_8601": "2025-08-04T14:04:48.322665Z",
"url": "https://files.pythonhosted.org/packages/e8/65/40a9b6e1c2c7a53968c4ac35067bc8692234f5287749a93f02c13bb9e6cb/comment_remover_cli-1.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-04 14:04:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "guider23",
"github_project": "Comms",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "comment-remover-cli"
}