# cmr1-cli

> Generic CLI helper

Latest version **0.1.16** (published 2019-07-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install cmr1-cli
pnpm add cmr1-cli
yarn add cmr1-cli
bun add cmr1-cli
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.16 |
| Published | 2019-07-24 |
| First published | 2017-01-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 1.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Charlie McClung |
| Maintainers | cmr1 |

## Links

- npm: https://www.npmjs.com/package/cmr1-cli
- Repository: https://github.com/cmr1/node-cli
- Homepage: https://github.com/cmr1/node-cli#readme
- Issues: https://github.com/cmr1/node-cli/issues
- npm.io page: https://npm.io/package/cmr1-cli

## Dependencies (6)

- [colors](https://npm.io/package/colors.md) ^1.1.2
- [extend](https://npm.io/package/extend.md) ^3.0.0
- [cmr1-logger](https://npm.io/package/cmr1-logger.md) ^0.1.2
- [readline-sync](https://npm.io/package/readline-sync.md) ^1.4.6
- [command-line-args](https://npm.io/package/command-line-args.md) ^3.0.5
- [command-line-usage](https://npm.io/package/command-line-usage.md) ^4.0.0

## Recent versions

- 0.1.16 (latest) — 2019-07-24
- 0.1.15 — 2019-06-06
- 0.1.14 — 2019-04-03
- 0.1.13 — 2018-10-10
- 0.1.11 — 2018-07-03
- 0.1.10 — 2018-07-03
- 0.1.9 — 2018-02-06
- 0.1.8 — 2017-11-18
- 0.1.7 — 2017-11-18
- 0.1.6 — 2017-02-08
- 0.1.5 — 2017-02-08
- 0.1.2 — 2017-02-04
- 0.1.1 — 2017-02-03
- 0.1.0 — 2017-01-31
- 0.0.8 — 2017-01-31
- … 1 more at https://npm.io/package/cmr1-cli/versions

## README

[![npm version](https://badge.fury.io/js/cmr1-cli.svg)](https://www.npmjs.com/package/cmr1-cli)
[![build status](https://travis-ci.org/cmr1/node-cli.svg?branch=master)](https://travis-ci.org/cmr1/node-cli)

# cli-node
NodeJS CLI module

## Example: (from `scratch.js`)
```javascript
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}'`);
});


```

### Example console output:
**Command:** `node scratch.js --src /path/to/input/file --timeout 1000 -fv`


![Example console output](docs/img/cmr1-cli-scratch-out.png?raw=true)


### Example help menu:
**Command:** `node scratch.js --help`


![Example help menu](docs/img/cmr1-cli-scratch-help.png?raw=true)

---
_Source: https://npm.io/package/cmr1-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
