cmr1/node-cli

View on GitHub
docs/index.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Home</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="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Home</h1>

    



    


    <h3> </h3>










    




    <section>
        <article><p><a href="https://www.npmjs.com/package/cmr1-cli"><img src="https://badge.fury.io/js/cmr1-cli.svg" alt="npm version"></a>
<a href="https://travis-ci.org/cmr1/node-cli"><img src="https://travis-ci.org/cmr1/node-cli.svg?branch=master" alt="build status"></a></p>
<h1>cli-node</h1>
<p>NodeJS CLI module</p>
<h2>Example: (from <code>scratch.js</code>)</h2>
<pre class="prettyprint source lang-javascript"><code>const Cmr1Cli = require('cmr1-cli');

const additionalOptions = [
  { 
    name: 'src', 
    alias: 's', 
    type: String, 
    multiple: true, 
    defaultOption: true, 
    description: 'Input source', 
    typeLabel: '[underline]{file}' 
  },
  { 
    name: 'timeout', 
    alias: 't', 
    type: Number, 
    description: 'Timeout', 
    typeLabel: '[underline]{ms}' 
  }
];

const myCli = new Cmr1Cli({
  name: 'My CLI script name',
  description: 'A description of this script',
  helpHeader: 'Available Options',
  optionDefinitions: additionalOptions,
  logging: {
    test: {
      verbose: true,  // Consider this debug, only show when verbose
      throws: false,  // Should this log type throw an Error?
      stamp: true,    // Also prefix log output with a timestamp
      prefix: 'Test', // Prefix string to show before each log msg
      color: 'blue'   // Color of output text (FG only)
    }
  }
});

Object.keys(myCli.settings.logging).forEach(type => {
  myCli[type](`This is a(n) ${type} message!`);
  myCli[type](`Called using: myCli.${type}('message')`)
});

additionalOptions.forEach(option => {
  const name = option.name;
  const value = myCli.options[name];

  myCli.log(`Option '${name}' = '${value}'`);
});


</code></pre>
<h3>Example console output:</h3>
<p><strong>Command:</strong> <code>node scratch.js --src /path/to/input/file --timeout 1000 -fv</code></p>
<p><img src="docs/img/cmr1-cli-scratch-out.png?raw=true" alt="Example console output"></p>
<h3>Example help menu:</h3>
<p><strong>Command:</strong> <code>node scratch.js --help</code></p>
<p><img src="docs/img/cmr1-cli-scratch-help.png?raw=true" alt="Example help menu"></p></article>
    </section>






</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Cli.html">Cli</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Wed Jul 24 2019 11:21:15 GMT-0600 (MDT)
</footer>

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