# common-bin-plus

> advanced common-bin for cli usage

Latest version **2.0.1** (published 2022-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install common-bin-plus
pnpm add common-bin-plus
yarn add common-bin-plus
bun add common-bin-plus
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2022-05-24 |
| First published | 2018-12-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 11.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | TZ |
| Maintainers | eggjs-admin, fengmk2, atian25, dead_horse, popomore, wanghx, hyj1991, killagu, coolme200, mansonchor.zzw, hubcarl |

## Links

- npm: https://www.npmjs.com/package/common-bin-plus
- Repository: https://github.com/node-modules/common-bin-plus
- Issues: https://github.com/node-modules/common-bin-plus/issues
- npm.io page: https://npm.io/package/common-bin-plus

## Dependencies (5)

- [consola](https://npm.io/package/consola.md) ^2.15.3
- [enabled](https://npm.io/package/enabled.md) ^2.0.0
- [std-env](https://npm.io/package/std-env.md) ^2.3.0
- [inquirer](https://npm.io/package/inquirer.md) ^8.1.0
- [common-bin](https://npm.io/package/common-bin.md) ^2.9.0

## Recent versions

- 2.0.1 (latest) — 2022-05-24
- 2.0.0 — 2021-06-10
- 1.0.2 — 2019-04-23
- 1.0.1 — 2018-12-29
- 1.0.0 — 2018-12-29
- 0.0.2 — 2018-12-29
- 0.0.1 — 2018-12-26

## README

# common-bin-plus

advanced [common-bin](https://github.com/node-modules/common-bin) for cli usage

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![NPM download][download-image]][download-url]

[npm-image]: https://img.shields.io/npm/v/common-bin-plus.svg?style=flat-square
[npm-url]: https://npmjs.org/package/common-bin-plus
[travis-image]: https://img.shields.io/travis/node-modules/common-bin-plus.svg?style=flat-square
[travis-url]: https://travis-ci.org/node-modules/common-bin-plus
[codecov-image]: https://codecov.io/gh/node-modules/common-bin-plus/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/node-modules/common-bin-plus
[david-image]: https://img.shields.io/david/node-modules/common-bin-plus.svg?style=flat-square
[david-url]: https://david-dm.org/node-modules/common-bin-plus
[snyk-image]: https://snyk.io/test/npm/common-bin-plus/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/common-bin-plus
[download-image]: https://img.shields.io/npm/dm/common-bin-plus.svg?style=flat-square
[download-url]: https://npmjs.org/package/common-bin-plus

## Installation

```bash
npm i common-bin-plus --save
```

## Write your own cli

see [common-bin](https://github.com/node-modules/common-bin) for more details.

## Feature

### Logger

https://github.com/unjs/consola

```js
this.logger.info('hello info level');
this.logger.warn('hello warn level');
this.logger.error(new Error('hello error level'));
this.logger.debug('hello debug level');
```

`debug` log is disabled by default, you could enable it by:

- command line argv: `--verbose`
- process env: `DEBUG=*` or `DEBUG=${cliName}`
- programmatically: `logger.level = 'DEBUG'`

## Prompt

```js
const answers = await this.prompt([
  {
    type: 'input',
    name: 'name',
    message: 'What is your name:',
  }, {
    type: 'list',
    name: 'type',
    message: 'Choose a boilerplate:',
    choices: [ 'empty', 'simple', 'plugin', 'framework' ],
  },
], {});

this.logger.info(answers);
```

## Unit Testing

Use [coffee](https://github.com/node-modules/coffee) :

```js
const coffee = require('coffee');

describe('test/index.test.js', () => {
  it('should work', () => {
    return coffee.fork('/path/to/cli')
      // .debug()
      .waitForPrompt()
      .write('tz\n')
      .writeKey('DOWN', 'ENTER')
      .write('this is a desc\n')
      .expect('stdout', /{ name: 'tz', type: 'simple' }/)
      .expect('stdout', /{ description: 'this is a desc' }/)
      .expect('code', 0)
      .end();
  });
}):
```

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