# impulse-bin

> CLI module runner

Latest version **0.2.0** (published 2015-03-25) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install impulse-bin
pnpm add impulse-bin
yarn add impulse-bin
bun add impulse-bin
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2015-03-25 |
| First published | 2013-05-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | David Smith |
| Maintainers | codeactual |
| Keywords | console, bin, bin script, cli, cli script, runner |

## Links

- npm: https://www.npmjs.com/package/impulse-bin
- Repository: https://github.com/codeactual/impulse-bin
- Issues: https://github.com/codeactual/impulse-bin/issues
- npm.io page: https://npm.io/package/impulse-bin

## Dependencies (4)

- [extend](https://npm.io/package/extend.md) ^2.0.0
- [long-con](https://npm.io/package/long-con.md) ^0.1.3
- [cli-color](https://npm.io/package/cli-color.md) ^0.2.3
- [configurable](https://npm.io/package/configurable.md) 0.0.1

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2015-03-25
- 0.1.4 — 2013-08-12
- 0.1.3 — 2013-05-23
- 0.1.2 — 2013-05-08
- 0.1.1 — 2013-05-07
- 0.1.0 — 2013-05-07

## README

# impulse-bin

node.js CLI module runner

* Adapters for [commander.js](https://github.com/visionmedia/commander.js) and [node-optimist](https://github.com/substack/node-optimist)
* Basic set of [long-con](https://github.com/codeactual/long-con) console loggers for stdout/stderr/verbose with [color](https://github.com/medikoo/cli-color)

[![Build Status](https://travis-ci.org/codeactual/impulse-bin.png)](https://travis-ci.org/codeactual/impulse-bin)

## Purpose

* CLI scripts that are easier to test without running the executable.
* Reduce boilerplate.

## Example

### `bin/myproj`

Executables are reduced to thin loading calls.

```js
var bin = require('impulse-bin').create();
bin.run(require('commander'), require('./lib/cli/myproj'));

// Or if your CLI module's run() function is a generator:
bin.runGenerator(require('commander'), require('./lib/cli/myproj'));
```

### `lib/cli/myproj.js`

While the rest is separated into input parsing and input consumption.

* `init()` receives a CLI input `provider` like `commander.js` or `node-optimist` for you to configure.
* `run()` receives the parsed `this.options` and `this.args` from the `provider`.

```js
exports.init = function(provider) {
  provider.option('-c, --config <dir>', 'Config file');
};

exports.run = function() {
  this.exitOnMissingOption(['config']);

  this.stdout('using config file: %s', this.clc.green(this.options.config));

  // ...
};
```

### Pass arguments from `bin/myproj` to the `lib/cli/myproj.js`

```js
// bin/myproj
bin.run(require('commander'), require('./lib/cli/myproj'), 1, 2, 3);

// lib/cli/myproj.js
exports.run = function() {
  console.log([].slice.call(arguments)); // [1, 2, 3]
};
```

## Installation

### [NPM](https://npmjs.org/package/impulse-bin)

[![NPM](https://nodei.co/npm/impulse-bin.png?downloads=true)](https://nodei.co/npm/impulse-bin/)

    npm install impulse-bin

## Documentation

* [exports.run()](docs/exports-run.md)
* [API](docs/ImpulseBin.md)

## License

  MIT

## Tests

    npm test

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