0.0.5 • Published 9 years ago
@joegesualdo/prompt-node v0.0.5
prompt 
Command line prompt.

Highlights
- Supports validation
- Hides password
Install
$ npm install --save @joegesualdo/prompt-nodeUsage
import prompt from '@joegesualdo/prompt-node'
new Prompt('Are you tired?')
.on('done', answer => {
console.log(`You've answered '${answer}'`)
})
.begin()Test
$ npm testAPI
Prompt(text, [options])
Instantiates a new prompt
Params
| Name | Type | Default | Description |
|---|---|---|---|
| text | Array | | Test description |
Options
| Name | Type | Default | Description |
|---|---|---|---|
| hidden | Boolean | false | Should answer be hidden? |
| required | Boolean | false | Does it accept empty answers? |
| validation | Function | () => {return true} | Test if answer is valid |
Returns: prompt
import prompt from '@joegesualdo/prompt-node'
new Prompt('Are you tired?', {
required: true,
hidden: true,
validation: (answer) => {
return answer === 'woo';
}
})prompt.begin()
Starts the prompt
import prompt from '@joegesualdo/prompt-node'
new Prompt('Are you tired?')
.on('done', answer => {
console.log(`You've answered '${answer}'`)
})
.begin()prompt.on(type, fn)
Sets lifecycle methods
Params
| Name | Type | Default | Description | Possible values |
|---|---|---|---|---|
| type | String | N/A | The lifecycle name | backspace, keypress, validationError, change, done |
| fn | Function | N/A | Function to run | N/A |
import prompt from '@joegesualdo/prompt-node'
new Prompt('Are you tired?')
.on('validationError', answer => {
})
.on('backspace', () => {
})
.on('change', (oldStr, newStr ) => {
})
.on('done', answer => {
console.log(`You've answered '${answer}'`)
})
.begin()Build
$ npm run buildLicense
MIT © Joe Gesualdo