# cycle-shell

> [![Build status][travis-image]][travis-url] [![Git tag][git-image]][git-url] [![NPM version][npm-image]][npm-url] [![Code style][standard-image]][standard-url]

Latest version **0.4.22** (published 2016-11-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install cycle-shell
pnpm add cycle-shell
yarn add cycle-shell
bun add cycle-shell
```

## 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.4.22 |
| Published | 2016-11-12 |
| First published | 2016-01-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 18 |
| Known vulnerabilities | 0 (+9 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | danleavitt0 |
| Maintainers | danleavitt0 |

## Links

- npm: https://www.npmjs.com/package/cycle-shell
- Repository: https://github.com/danleavitt0/cycle-shell
- Homepage: https://github.com/danleavitt0/cycle-shell#readme
- Issues: https://github.com/danleavitt0/cycle-shell/issues
- npm.io page: https://npm.io/package/cycle-shell

## Dependencies (18)

- [vdux](https://npm.io/package/vdux.md) 2.4.10
- [yoco](https://npm.io/package/yoco.md) 1.6.2
- [lodash](https://npm.io/package/lodash.md) 3.10.1
- [domready](https://npm.io/package/domready.md) 1.0.8
- [@f/reduce](https://npm.io/package/@f/reduce.md) 1.0.0
- [redux-flo](https://npm.io/package/redux-flo.md) 2.2.0
- [@f/map-gen](https://npm.io/package/@f/map-gen.md) 1.6.0
- [@f/is-array](https://npm.io/package/@f/is-array.md) 1.1.1
- [redux-multi](https://npm.io/package/redux-multi.md) 0.1.12
- [shell-quote](https://npm.io/package/shell-quote.md) 1.4.3
- [@f/equal-obj](https://npm.io/package/@f/equal-obj.md) 1.2.1
- [@f/is-number](https://npm.io/package/@f/is-number.md) 1.1.1
- [@f/is-string](https://npm.io/package/@f/is-string.md) 1.1.1
- [@f/reduce-key](https://npm.io/package/@f/reduce-key.md) 1.2.0
- [@f/is-generator](https://npm.io/package/@f/is-generator.md) 1.3.2
- [@f/create-action](https://npm.io/package/@f/create-action.md) 1.1.1
- [component-emitter](https://npm.io/package/component-emitter.md) ^1.2.1
- [regenerator-runtime](https://npm.io/package/regenerator-runtime.md) ^0.9.6

## Recent versions

- 0.4.22 (latest) — 2016-11-12
- 0.4.21 — 2016-11-12
- 0.4.20 — 2016-11-12
- 0.4.19 — 2016-09-29
- 0.4.18 — 2016-09-29
- 0.4.17 — 2016-09-29
- 0.4.16 — 2016-09-29
- 0.4.15 — 2016-09-29
- 0.4.14 — 2016-07-21
- 0.4.13 — 2016-07-21
- 0.4.12 — 2016-07-21
- 0.4.11 — 2016-05-02
- 0.4.10 — 2016-05-02
- 0.4.9 — 2016-04-25
- 0.4.8 — 2016-04-13
- … 20 more at https://npm.io/package/cycle-shell/versions

## README

# cycle shell

[![Build status][travis-image]][travis-url]
[![Git tag][git-image]][git-url]
[![NPM version][npm-image]][npm-url]
[![Code style][standard-image]][standard-url]

A programmable web based shell-like interface

## Installation
```
npm install cycle-shell
```

## Usage
```js
import cycle from 'cycle-shell'

cycle(main, {
  welcome: 'Welcome to my shell.'
})

function main (input) {
  return input
}
```

## API

### cycle(update, opts)
Initialize a cycle shell instance. By default, the cycle shell will be placed in the `<body>` of the document.

**Returns** Process count listener

```js
var counter = require('cycle-shell')(main)
counter(function (num) {
  console.log(num)
})
```

##### `update`
- type: `function`
- An update function that gets run when the input box is submitted

##### `opts`
- type: `object`

###### welcome
- type: `string`
- A message to be displayed when the shell is first run

###### title
- type: `string`
- The title of the game/application to be displayed next to the input box

###### view
- type: `function`
- The return value from the `main` function gets run through the view function to produce a valid output.

The default view function is set up to handle objects, arrays, strings, numbers, and [vdux](https://github.com/vdux/vdux) components.
```js
const defaultView = (output) => {
  if (typeof (output) !== 'object' || output.props) {
    return output
  } else if (isArray(output)) {
    output.join('\n')
  } else {
    return reduce((arr, item, key) => {
      arr.push(`${key}: ${item}`)
      return arr
    }, [], output).join('\n')
  }
}
```

###### initialState
- type: `object`
- set an initial state for the application

###### middleware
- type: `function || generator`
- Connect custom middleware to cycle shell

### out(msg)
Exposed out action for adding messages to the output log.

##### `msg`
- type: `string`
- A message to be placed in the output log.

[travis-image]: https://img.shields.io/travis/danleavitt0/cycle-shell.svg?style=flat
[travis-url]: https://travis-ci.org/danleavitt0/cycle-shell
[git-image]: https://img.shields.io/github/tag/danleavitt0/cycle-shell.svg?style=flat
[git-url]: https://github.com/danleavitt0/cycle-shell
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat
[standard-url]: https://github.com/feross/standard
[npm-image]: https://img.shields.io/npm/v/cycle-shell.svg?style=flat
[npm-url]: https://npmjs.org/package/cycle-shell

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