Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/andykog/castle


https://github.com/andykog/castle

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

Castle
======

Terminal utils for happy scripting

[![Build Status](https://travis-ci.org/andykog/castle.svg?branch=master&t=0)](https://travis-ci.org/andykog/castle)

Installing
----------

```
npm install castle
```

API
---

### castle.prompt(message, options);

**message** (string, required) — message to display
**options** (object, optional) — see options below:

| option | type | default value | description |
| ------------ | ------------ | ------------ | ------------ |
| allowEmpty | boolean | true | If `false` will ask again on empty input |
| defaultValue | string | undefined | Uses default value on empty input |
| style | string | prompt.Style.Default | Specifies prompt color, supported values: `prompt.Style.Default`, `prompt.Style.Dangerous` (red) |

```js
const {prompt} = require('castle');

prompt('Your name');
```

prompt

```js
const name = await prompt('Your name', {defaultValue: 'Anonymous'});
```

prompt with default value

### castle.confirm(message, options);

**message** (string, required) — message to display
**options** (object, optional) — see options below:

| option | type | default value | description |
| ------------ | ------------ | ------------ | ------------ |
| allowEmpty | boolean | true | If `false` will ask again on empty input, otherwise treats empty input as negative answer |
| defaultValue | boolean | undefined | Uses default value on empty input |
| style | string | prompt.Style.Default | Specifies prompt color, supported values: `confirm.Style.Default`, `confirm.Style.Dangerous` (red) |

```js
const {confirm} = require('castle');

const isConfirmed = await confirm('Proceed?');
```

confirm