1.0.0 • Published 4 years ago

duologue v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

duologue

A simple implementation of a terminal prompt for nodeJS. It uses node's readline package to read terminal input and takes advantage of promises and async / await to capture and validate user input.

Features

  • custom messages per prompt.
  • optional input validation.

example

const { duologue } = require('duologue');

const run = async () => {
  const name = await duologue('Enter a name')
  console.log(name);
  const date = await duologue('Enter your Date! ', (out) => {
    const dateFomat = /((0[1-9])|[1-2][0-9]|3[0-1])-(0[1-9]|1[0-2])-([0-9]{4})/
    return dateFomat.test(out)
  });
  console.log(date)
}


run();