Recently I released a new bit of rust code: Commenteer. This software was designed with one simple thing in mind. To add comment headers to large code-bases without the need to manually open every file in a text editor. Most "heavy" editors these days can do this for you but are a bear to use. Eclipse, any of the JetBrains IDEs, and Emacs all support this. You can even achieve this in Vim. But for me this seemed over-complicated for the task.
Commenteer is a simple command line utility that takes a few simple arguments and automates the whole process. Here is the help info:
Commenteer 0.2.1 Chad Baxter <firstname.lastname@example.org> Add comment headers to code. USAGE: commenteer [FLAGS] [OPTIONS] --input <input>... FLAGS: -h, --help Prints help information -r, --recurse Add header to every text file in the specified path. -V, --version Prints version information -v, --verbose Show verbose information about the operation OPTIONS: -c, --comment-file <comment-file> A path to a file containing the header you would like to add. -t, --comment-text <comment-text> A string containing the header you would like to add. Can contain control characters that use backslashes(\n, \t etc). -n, --ignore <ignore>... Paths to files you would like to exclude from being modified -i, --input <input>... List of paths or files to add a header to.
As you can see Commenteer supports reading a comment header from a file or accepting it from the command line. It supports recursive commenting of all code in a directory as well as ignoring specific files.
an example command for reading from a file and applying changes recursively:
/*╭──────────────────────╮ │ Author: Chad Baxter │ │ Date: │ │ For: │ ╰──────────────────────╯*/
commenteer -r -c ../comment.txt -i ./
An example command using an argument to accept the comment:
commenteer -r -t "/*╭──────────────────────╮\n │ Author: Chad Baxter │\n │ Date: │\n │ For: │ \n╰──────────────────────╯*/"
My hopes are to give this program the ability to identify the types of code and apply the correct comment syntax to provided comment text. For example
// for C-style comments
# for bash style comments etc. I am thinking that simply parsing any code for the existence of a comment and using that comment style may work. Or perhaps just adding a hardcoded list of comment styles and allowing selection of a style from the cli.
This application is currently pretty rough around the edges and has a number of bugs that could really mess up your code if you aren't careful. Always commit your changes before using Commenteer and roll back your repository if it does mess things up. I am currently aware of an bug in ignore list processing that may cause only the first ignored file to be recognized. This is a problem with how my application handles
clap arguments. Contributions are welcome at: https://github.com/LogoiLab/commenteer