[go: nahoru, domu]

Skip to content

dyne/tgcom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tgcom

toggle comments in source files




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.

tgcom Features

  • 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.


💾 Install

go get github.com/dyne/tgcom

🔝 back to top


🎮 Quick start

Basic Command

tgcom --file <filename> --line <line_number> --action <comment|uncomment|toggle>

Examples

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

🔝 back to top


📜 Requirements

  1. 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.
  2. 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.
  3. 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.
  4. Performance:

    • The tool must be fast and efficient.
    • Avoid loading the entire file into memory.
  5. 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>.
  6. Testing:

    • Include test units to ensure reliability and correctness of the software.
    • Tests should cover various scenarios and edge cases.

🔝 back to top


🚑 Community & support

📝 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.

🔝 back to top


🐋 Docker

Please refer to DOCKER PACKAGES

🔝 back to top


😍 Acknowledgements

Copyleft 🄯 2023 by Dyne.org foundation, Amsterdam

Designed, written and maintained by Puria Nafisi Azizi.

🔝 back to top


👤 Contributing

Please first take a look at the Dyne.org - Contributor License Agreement then

  1. 🔀 FORK IT
  2. Create your feature branch git checkout -b feature/branch
  3. Commit your changes git commit -am 'feat: New feature\ncloses #398'
  4. Push to the branch git push origin feature/branch
  5. Create a new Pull Request gh pr create -f
  6. 🙏 Thank you

🔝 back to top


💼 License

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/>.

🔝 back to top

About

No description, website, or topics provided.

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages