# commander-rxjs

> A simple adapter to easily use RxJS with commander.

Latest version **0.0.6** (published 2016-12-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install commander-rxjs
pnpm add commander-rxjs
yarn add commander-rxjs
bun add commander-rxjs
```

## 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.0.6 |
| Published | 2016-12-06 |
| First published | 2016-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | nickbreaton |
| Maintainers | nickbreaton |

## Links

- npm: https://www.npmjs.com/package/commander-rxjs
- Repository: https://github.com/nickbreaton/commander-rxjs
- Homepage: https://github.com/nickbreaton/commander-rxjs#readme
- Issues: https://github.com/nickbreaton/commander-rxjs/issues
- npm.io page: https://npm.io/package/commander-rxjs

## Dependencies (1)

- [camel-case](https://npm.io/package/camel-case.md) ^3.0.0

## Recent versions

- 0.0.6 (latest) — 2016-12-06
- 0.0.5 — 2016-12-06
- 0.0.4 — 2016-12-04
- 0.0.3 — 2016-12-03
- 0.0.2 — 2016-12-02
- 0.0.1 — 2016-12-02

## README

# commander-rxjs

[![NPM Version](https://img.shields.io/npm/v/commander-rxjs.svg?style=flat-square)](https://www.npmjs.com/package/commander-rxjs)
[![TravisCI](https://img.shields.io/travis/nickbreaton/commander-rxjs/master.svg?style=flat-square)](https://travis-ci.org/nickbreaton/commander-rxjs)
[![Codecov](https://img.shields.io/codecov/c/github/nickbreaton/commander-rxjs.svg?style=flat-square)](https://codecov.io/gh/nickbreaton/commander-rxjs)

A simple adapter to easily use [RxJS](https://github.com/ReactiveX/RxJS) with [commander](https://github.com/tj/commander.js).

## Installation

```
$ npm install commander-rxjs
```

**Important:** `commander` and `rxjs` are both peer dependencies. You must install them alongside `commander-rxjs`.

```
$ npm install commander rxjs
```

## API

### `ObservableCommand`

`commander` exports an instance of a `Command`:

```js
import program from 'commander';

program
  .command('example')
  .action(options => {
    // do stuff
  });

program
  .parse(proces.argv);
```

`commander-rxjs` exports an instance of a wrapped `Command` known as an `ObservableCommand`.

The `ObservableCommand` has the exact same API as a `Command`, with the addition of one function, `observe()`, which is used in place of the `.action()` function:

```js
import program from 'commander-rxjs';

program
  .command('example')
  .observe()
  // ... do stream stuff
  .subscribe();

program
  .parse(proces.argv);
```

### `observe()`

returns an RxJS observable stream with the following data:

```js
{
  args: {
    'camelCasedArgument': 'value',
    '...': '...'
  },
  options: {
    'camelCasedOption': 'value',
    '...': '...'
  },
  command: Command // (commander raw command)
}
```

## Examples

Be sure to checkout all of the [examples](https://github.com/nickbreaton/commander-rxjs/tree/master/examples). They can easily be run with `npm run example:[example]`.

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