Giter VIP home page Giter VIP logo

email-prompt's Introduction

email-prompt

CLI email prompt featuring autocompletion and validation. Powers 𝚫now --login.

prompt

How to use

const prompt = require('email-prompt');
prompt({ /* opts */ })
.then((email) => {
  console.log('\n> Hello ' + val);
))
.catch(() => {
  console.log('\n> Aborted!');
})

To run the demo, clone the project and run:

$ npm install
$ node demo

Options

  • start (String): the beginning of the prompt. Defaults to > Enter your email:
  • domains (Set): domain names to autocomplete (as String). Defaults to:
    • aol.com
    • gmail.com
    • google.com
    • yahoo.com
    • ymail.com
    • hotmail.com
    • live.com
    • outlook.com
    • inbox.com
    • mail.com
    • gmx.com
  • forceLowerCase (Boolean): converts all input to lowercase. Defaults to true.
  • suggestionColor (String): a chalk color. Defaults to gray
  • autocompleteChars (Set): a set of chars that trigger autocompletion. Defaults to:
    • ↹ Tab
    • ↵ Return (enter)
    • → Right arrow
  • resolveChars (Set): a set of chars that resolve the promise. Defaults to ↵return
  • abortChars (Set): a set of chars that abort the process. Defaults to Ctrl+C
  • allowInvalidChars (Boolean): controls whether non-email chars are accepted. Defaults to false

Notes

Some important implementation details:

  • email-prompt automatically adapts the mode of process.stdin for you.
  • The stdin stream is resumed and paused upon the promise being settled.
  • When the promise resolves or rejects, the previous stdin mode is restored.
  • The tty mode is set to raw, which means all the caret interactions that you come to expect in a regular stdin prompt are simulated. This gives us fine-grained control over the output and powers the validation.

email-prompt's People

Contributors

nkzawa avatar rauchg avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.