1.0.0-beta.0 • Published 4 years ago

border-comment-builder v1.0.0-beta.0

Weekly downloads
1
License
GPL-3.0
Repository
gitlab
Last release
4 years ago

Border comment builder

What is this?

This is a tool that transforms text you put in stdin into a nice border like that:

/*
 * +---------------------+
 * | Nice block comment! |
 * +---------------------+
 */

You can insert that thing anywhere in your source code. It would be good to use it in a begin part of your source code.

Written in Node.js.

Launching app

Install app globally:

npm i -g border-comment-builder --unsafe-perm=true

And after that border-comment-builder terminal command will be available.

You can also start app with parameters:

border-comment-builder --type python --input comment.txt --output out.txt

echo and pipe calls help you get result on single line situation:

echo "Only single line comment" | border-comment-builder --type twig

JS API usage

You can tweak borders whatever you want.

A BorderCommentBuilder constructor gets an object of params and returns compiled string.

BorderCommentBuilder constructor options

An example:

const resultString = new BorderCommentBuilder({
  text: "123\n456",
  sideSymbolLeft: "< ",
  sideSymbolRight: " >",
  cornerSymbol: "U",
}).build();

Compiled string will be:

/*
 * U-----U
 * < 123 >
 * < 456 >
 * U-----U
 */

Types of comments (predefined)

js and also by default

/*
 * +-------+
 * | a b c |
 * +-------+
 */

c

  //
  // +-------+
  // | a b c |
  // +-------+
  //

pascal

  (*
   * +-------+
   * | a b c |
   * +-------+
   *)

python

  #
  # +-------+
  # | a b c |
  # +-------+
  #

html

<!--
    -- +-------+
    -- | a b c |
    -- +-------+
    -->

twig

  {#
   # +-------+
   # | a b c |
   # +-------+
   #}

All these borders defined in pre-defined-borders.json file.

CLI util arguments

argvDescription
--type <type_of comment>Type of comment. See "Types of comments" section
--input <my_comment.txt>File containing comment to be processed
--output <result.txt>File where result comment will be written
--before-border "(%"beforeBorder option
--middle-border " % "middleBorder option
--after-border "%)"afterBorder option
--border-symbol "="borderSymbol option
--corner-symbol "#"cornerSymbol option
--side-symbol-left "/"sideSymbolLeft option
--side-symbol-right "\\"sideSymbolRight option

The text of comment sets line-by-line from cli, but also can be read from file.

When you finish writing the text press any of EOF combination (Ctrl+D in Unix-like systems and Ctrl+Z in Win).

Additional commands

  • npm run build generates build directory.

  • npm run clean removes build directory.

  • npm run test launches Mocha test utility to check some costructor calls going right.

1.0.0-alpha.8

4 years ago

1.0.0-alpha.7

4 years ago

1.0.0-alpha.6

4 years ago

1.0.0-alpha.5

4 years ago

1.0.0-alpha.4

4 years ago

1.0.0-alpha.3

4 years ago

1.0.0-alpha.2

4 years ago

1.0.0-beta.0

4 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago