tgcom
is a command-line tool designed to comment, uncomment, and toggle comments in source code files. It supports multiple languages including JavaScript, Go, and Bash, and can be extended to support more. The tool can handle single lines, ranges of lines, and a mix of both. It also supports handling streams from stdin and processes multiple files and ranges in one command.
- Comment/Uncomment/Toggle Comments: Operate on single lines, ranges, or a mixture of both.
- Multi-language Support: Supports JavaScript, Go, Bash, and can be extended to other languages.
- File Handling: Works with filenames or streams from stdin.
- Backup Creation: Automatically creates a backup before modifying a file.
- Performance: Fast and efficient, does not load the entire file into memory.
- Labels for Sections: Supports labels for commenting sections in the style of heredocs.
go get github.com/dyne/tgcom
tgcom --file <filename> --line <line_number> --action <comment|uncomment|toggle>
Comment a Single Line
tgcom --file main.go --line 10 --action comment
Uncomment a Range of Lines
tgcom --file main.go --lines 10-20 --action uncomment
Toggle Comments on Multiple Files and Lines
tgcom --files main.go:10-20,script.sh:4,index.html:#<p>,#</p> --action toggle
Using Stdin
cat main.go | tgcom --line 10 --action comment
Using Labels for Sections
tgcom --file main.go --start-label START --end-label END --action comment
-
Language Support:
- The software must support at least JavaScript, Go, and Bash for commenting/uncommenting/toggling lines.
- It should be extensible to support additional programming languages.
-
File Handling:
- Accept filenames as input and work on streams from stdin.
- Replace the files in place after making changes.
- Create a backup of the original file before making any changes.
- Provide a dry-run option to print the changes to stdout instead of modifying the files in place.
-
Commenting Functionality:
- Comment, uncomment, and toggle comments for:
- Single lines
- Ranges of lines
- A mixture of single lines and ranges
- Accept labels for commenting sections, such as heredocs with a start keyword and an end keyword in source files.
- Comment, uncomment, and toggle comments for:
-
Performance:
- The tool must be fast and efficient.
- Avoid loading the entire file into memory.
-
User Interface:
- Provide a command-line interface (CLI) for user interaction.
- Allow the CLI to handle multiple files and complex input specifications, such as
main.js:10-20 script.sh:4 index.html:#<p>,#</p>
.
-
Testing:
- Include test units to ensure reliability and correctness of the software.
- Tests should cover various scenarios and edge cases.
📝 Documentation - Getting started and more.
🌱 Ecosystem - Plugins, resources, and more.
🚩 Issues - Bugs end errors you encounter using tgcom.
💬 Discussions - Get help, ask questions, request features, and discuss tgcom.
[] Matrix - Hanging out with the community.
🗣️ Discord - Hanging out with the community.
🪁 Telegram - Hanging out with the community.
📖 Example - An example repository that uses tgcom.
Please refer to DOCKER PACKAGES
Copyleft 🄯 2023 by Dyne.org foundation, Amsterdam
Designed, written and maintained by Puria Nafisi Azizi.
Please first take a look at the Dyne.org - Contributor License Agreement then
- 🔀 FORK IT
- Create your feature branch
git checkout -b feature/branch
- Commit your changes
git commit -am 'feat: New feature\ncloses #398'
- Push to the branch
git push origin feature/branch
- Create a new Pull Request
gh pr create -f
- 🙏 Thank you
tgcom - toggle comments in source files
Copyleft 🄯 2023 Dyne.org foundation, Amsterdam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.