listr-input

0.2.1 • Public • Published

listr-input Build Status

Input module for Listr

Install

$ npm install --save listr-input

Usage

const Listr = require('listr');
const input = require('listr-input');
const got = require('got');
 
const list = new Listr([
    {
        title: 'Retrieving data',
        task: () => input('Credentials', {
            secret: true,
            validate: value => value.length > 0,
            done: credentials => got('https://myapi.com', {
                headers: {
                    'Authorization': `Bearer ${credentials}`
                }
            })
        })
    }
]);
 
list.run();

API

input(question, [options])

Returns an Observable which asks for user input.

question

Type: string

Question to ask.

options

default

Type: string

Default value to use if nothing is entered.

validate

Type: function

Function which accepts the provided value. Should return true if the value is valid, false otherwise.

secret

Type: boolean
Default: false

Mark the input as secret.

done

Type: function

Function that will be invoked when the user has answered the question.

autoSubmit

Type: function

Function which accepts the provided value. If returns true then the value will be submitted automatically.

License

MIT © Sam Verschueren

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.1
    96,750
    • latest
  • 0.1.1
    2
    • [object Object]

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.1
    96,750
  • 0.2.0
    75
  • 0.1.3
    3,479
  • 0.1.2
    56
  • 0.1.1
    2
  • 0.1.0
    2

Package Sidebar

Install

npm i listr-input

Weekly Downloads

100,364

Version

0.2.1

License

MIT

Unpacked Size

4.66 kB

Total Files

4

Last publish

Collaborators

  • samverschueren