Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andykog/castle
https://github.com/andykog/castle
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/andykog/castle
- Owner: andykog
- Created: 2020-05-11T11:48:50.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-05-14T16:32:09.000Z (over 4 years ago)
- Last Synced: 2024-10-14T05:26:08.334Z (3 months ago)
- Language: JavaScript
- Size: 51.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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');
``````js
const name = await prompt('Your name', {defaultValue: 'Anonymous'});
```### 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?');
```