ShogunPanda/chalkbars

View on GitHub
docs/index.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Home - Documentation</title>

    <script src="scripts/prettify/prettify.js"></script>
    <script src="scripts/prettify/lang-css.js"></script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>

<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
  <div class="navicon"></div>
</label>

<label for="nav-trigger" class="overlay"></label>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="chalkbars.module_configuration.html">configuration</a></li><li><a href="module-chalkbars.html">chalkbars</a><ul class='methods'><li data-type='method'><a href="module-chalkbars.html#.error">error</a></li><li data-type='method'><a href="module-chalkbars.html#.format">format</a></li><li data-type='method'><a href="module-chalkbars.html#.formatNoColor">formatNoColor</a></li><li data-type='method'><a href="module-chalkbars.html#.log">log</a></li><li data-type='method'><a href="module-chalkbars.html#.plainFormat">plainFormat</a></li><li data-type='method'><a href="module-chalkbars.html#.style">style</a></li></ul></li></ul>
</nav>

<div id="main">
    

    



    









    


    <section class="readme">
        <article><h1>chalkbars</h1><p><a href="http://badge.fury.io/js/chalkbars"><img src="https://badge.fury.io/js/chalkbars.png" alt="Gem Version"></a>
<a href="https://gemnasium.com/ShogunPanda/chalkbars"><img src="https://gemnasium.com/ShogunPanda/chalkbars.png?travis" alt="Dependency Status"></a>
<a href="http://travis-ci.org/ShogunPanda/chalkbars"><img src="https://secure.travis-ci.org/ShogunPanda/chalkbars.png?branch=master" alt="Build Status"></a>
<a href="https://coveralls.io/github/ShogunPanda/chalkbars?branch=master"><img src="https://coveralls.io/repos/github/ShogunPanda/chalkbars/badge.svg?branch=master" alt="Coverage Status"></a></p>
<p>Template based terminal coloring based on <a href="https://www.npmjs.com/package/chalk">Chalk</a> and <a href="http://handlebarsjs.com">Handlebars</a>.</p>
<p>http://sw.cowtech.it/chalkbars</p>
<h2>Usage</h2><p>Chalkbars allows an easier use of chalk on the console taking advantage of the awesome Handlebars templating engine.</p>
<p>The use is really easy:</p>
<pre class="prettyprint source lang-javascript"><code>var chalkbars = require(&quot;chalkbars&quot;).format;
console.log(chalkbars(&quot;{{#C red}}This is in red{{/C}} and this is not.&quot;));</code></pre><h2>Supported implementations.</h2><p>Chalkbars supports and has been tested on <a href="http://nodejs.org">NodeJS</a> 5.0+. </p>
<h2>Chalkbars Handlebars helpers</h2><h3>C</h3><p>This is the main template. It accepts one or more styles, concatenated by any character except letters, numbers and &quot;#&quot;. </p>
<p>Even thought quotes are optional, is advised to always provide them for clarity.</p>
<p>This template will replace text inside with the styles provided. </p>
<p>It supports nesting.</p>
<p>Examples:</p>
<pre class="prettyprint source lang-javascript"><code>console.log(chalkbars(&quot;{{#C red}}This is in red except for {{#C green}}this{{/C}} and it supports restoring.{{/C}}&quot;));
console.log(chalkbars(&quot;{{#C red.bgYellow}}This is in red with a yellow background.{{/C}}&quot;));
console.log(chalkbars(&quot;{{#C red$bgYellow}}Same as above.{{/C}}&quot;));</code></pre><p>Supported styles are:</p>
<ul>
<li>Default Chalk styles.</li>
<li><em>i#</em><strong>ABC</strong> (where ABC is a 3 digit number): The ANSI color code. Example: <strong>031</strong> is red foreground, <strong>042</strong> is green background.</li>
<li><em>x#</em><strong>ABC</strong> (where A, B, C are a number from 0 to 5): The 256 ANSI color code. For the meaning of the values, see <a href="https://github.com/jbnicolai/ansi-256-colors">ansi-256-colors</a>.</li>
<li><em>X#</em><strong>AABBCC</strong> (where AA, BB, CC ranges from 00 to FF): The RGB HEX color code.</li>
<li>User defined styles (see <code>chalkbars.style</code> below).</li>
</ul>
<p>All unrecognized styles are ignored.</p>
<h3>B</h3><p>Outputs a header with a word between brackets. </p>
<p>It does not support nesting and does not support any embedded content.</p>
<p>It accepts one or two arguments. The first argument is the word to print, the second argument is the style. If the latter is omitted, the first word is also used as a style.
Again, quoting is optional but advised.</p>
<p>Examples: </p>
<pre class="prettyprint source lang-javascript"><code>console.log(chalkbars(&quot;{{B info}} On the left you see a white 'INFO' word inside blue brackets&quot;));
console.log(chalkbars(&quot;{{B \&quot;info\&quot; \&quot;red\&quot;}} On the left you see a red 'INFO' word inside blue brackets&quot;));
console.log(chalkbars(&quot;{{B info red}} Omitting quotes might lead to unwanted behavior&quot;));
console.log(chalkbars(&quot;{{B \&quot;what\&quot; \&quot;red.bgYellow\&quot;}} On the left you see a red on yellow background 'WHAT' word inside blue brackets&quot;));</code></pre><h4>Shortcuts</h4><p>The following shortcut helpers are also defined:</p>
<ul>
<li><strong>BI</strong>: Shortand for <code>{{B &quot;info&quot;}}</code></li>
<li><strong>BW</strong>: Shortand for <code>{{B &quot;warn&quot;}}</code></li>
<li><strong>BO</strong>: Shortand for <code>{{B &quot;ok&quot;}}</code></li>
<li><strong>BF</strong>: Shortand for <code>{{B &quot;fail&quot;}}</code></li>
<li><strong>BE</strong>: Shortand for <code>{{B &quot;error&quot;}}</code></li>
<li><strong>BP</strong>: Shortand for <code>{{B &quot;pass&quot;}}</code></li>
<li><strong>BS</strong>: Shortand for <code>{{B &quot;skip&quot;}}</code></li>
<li><strong>BD</strong>: Shortand for <code>{{B &quot;debug&quot;}}</code></li>
</ul>
<h3>E</h3><p>Outputs a footer with a word between brackets</p>
<p>It behaves like <a href="#user-content-b">B</a> but it makes sure the message is printed to the right of the screen.</p>
<pre class="prettyprint source lang-javascript"><code>console.log(chalkbars(&quot;On the right you see a white 'INFO' word inside blue brackets {{E info}}&quot;));
console.log(chalkbars(&quot;On the right you see a red 'INFO' word inside blue brackets {{E \&quot;info\&quot; \&quot;red\&quot;}}&quot;));
console.log(chalkbars(&quot;Omitting quotes might lead to unwanted behavior {{E info red}}&quot;));
console.log(chalkbars(&quot;On the right you see a red on yellow background 'WHAT' word inside blue brackets {{B \&quot;what\&quot; \&quot;red.bgYellow\&quot;}}&quot;));</code></pre><h4>Shortcuts</h4><p>The following shortcut helpers are also defined:</p>
<ul>
<li><strong>EI</strong>: Shortand for <code>{{E &quot;info&quot;}}</code></li>
<li><strong>EW</strong>: Shortand for <code>{{E &quot;warn&quot;}}</code></li>
<li><strong>EO</strong>: Shortand for <code>{{E &quot;ok&quot;}}</code></li>
<li><strong>EF</strong>: Shortand for <code>{{E &quot;fail&quot;}}</code></li>
<li><strong>EE</strong>: Shortand for <code>{{E &quot;error&quot;}}</code></li>
<li><strong>EP</strong>: Shortand for <code>{{E &quot;pass&quot;}}</code></li>
<li><strong>ES</strong>: Shortand for <code>{{E &quot;skip&quot;}}</code></li>
<li><strong>ED</strong>: Shortand for <code>{{E &quot;debug&quot;}}</code></li>
</ul>
<h2>Configuring Chalkbars</h2><h3>chalkbars.configuration.silent</h3><p>Whether to ignore exceptions when compiling a Handlebars template fails. </p>
<p>If set to <code>false</code> a compilation failure will raise an exception.</p>
<p>The default value is <code>true</code>.</p>
<h3>chalkbars.configuration.openingBracket</h3><p>The default template for the opening bracket in the <a href="#user-content-b">B</a> and <a href="#user-content-e">E</a> templates.</p>
<p>The default value is <code>{{#C bracket}}[{{/C}}</code>.</p>
<h3>chalkbars.configuration.closingBracket</h3><p>The default template for the closing bracket in the <a href="#user-content-b">B</a> and <a href="#user-content-e">E</a> templates.</p>
<p>The default value is <code>{{#C bracket}}]{{/C}}</code>.</p>
<h3>chalkbars.configuration.styles</h3><p>The list of valid chalk styles for the <a href="#user-content-c">C</a>, <a href="#user-content-b">B</a> and <a href="#user-content-e">E</a> templates.  </p>
<p><strong>Do not modify this directly but use <a href="#user-content-chalkbarsstylename-value">chalkbars.style</a> instead.</strong></p>
<h2>API Documentation</h2><p>The API documentation can be found <a href="https://sw.cowtech.it/chalkbars/docs">here</a>.</p>
<h2>Contributing to chalkbars</h2><ul>
<li>Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.</li>
<li>Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.</li>
<li>Fork the project.</li>
<li>Start a feature/bugfix branch.</li>
<li>Commit and push until you are happy with your contribution.</li>
<li>Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.</li>
</ul>
<h2>Copyright</h2><p>Copyright (C) 2015 and above Shogun (shogun@cowtech.it).</p>
<p>Licensed under the MIT license, which can be found at http://opensource.org/licenses/MIT.</p></article>
    </section>






</div>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Thu Aug 18 2016 15:08:28 GMT+0200 (CEST) using the Minami theme.
</footer>

<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>