ask-readline

1.1.0 • Public • Published

ask-readline

Ask a question for CLI using readline, supports muted input

npm i ask-readline

Usage

const ask = require('ask-readline')

main()

async function main () {
  const username = await ask('Input username (clear): ', { clear: true })
  const password = await ask('Input password (clear and muted): ', { clear: true, muted: true })
  const twoFactorAuth = await ask('Input 2fa (keep but muted): ', { clear: false, muted: true })
  const alias = await ask('Input alias (default): ')

  console.log({ username, password, twoFactorAuth, alias })
}

API

const answer = await ask(question, [options])

answer is a string or null.
If user does CTRL+C then answer is null.

Available options:

{
  clear: false,
  muted: false
}

clear removes the line where the question was printed.
muted ensures that input is hidden, and not written to stdout.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i ask-readline

Weekly Downloads

26

Version

1.1.0

License

MIT

Unpacked Size

5.03 kB

Total Files

6

Last publish

Collaborators

  • lukks