1. listr-input
Input module for Listr
listr-input
Package: listr-input
Created by: SamVerschueren
Last modified: Sun, 19 Jun 2022 12:48:21 GMT
Version: 0.2.1
License: MIT
Downloads: 494,061
Repository: https://github.com/SamVerschueren/listr-input

Install

npm install listr-input
yarn add listr-input

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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code