Next: , Up: Working with comments   [Contents][Index]


5.1 comment: Create a comment block in a given style

Th comment command makes a comment in a given style. If no style is given, the comment is created in the C-style. For example:

$ echo "foo" | licensing comment
/* foo */

The comment command can also operate on files specified as arguments, but it does not modify those files. The result is always displayed on the standard output. For example:

$ echo "foo" > foo.txt
$ licensing comment foo.txt
/* foo */

To specify a particiular commenting style, use one of the common comment-style options (see Common Commenting-style options). For example:

$ echo "foo" | licensing comment --c++-style
// foo

This example makes a comment in the C++ style.

The preview command uses comment to help generate the current working boilerplate.

5.1.1 Dealing with indentation

The comment command tries to retain existing indentation by pushing the whole text to the right. When a block-style comment is being created the text is pushed three columns to the right. In the case of whole-line comments, the number of columns pushed is the size of the comment delimiter plus one.

$ cat foo.txt
    foo
    bar
$ licensing comment foo.txt 
/*     foo
       bar */

This example shows that 3 columns are added to the beginning of every line. The foo.txt file has four spaces of indentation, and the result moves the ‘foo’ and ‘bar’ to the seventh column.

When a block-style comment is being created, and the final line of the comment is over 78 characters, the closing delimiter is placed on the following line by itself.


Next: , Up: Working with comments   [Contents][Index]