You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

email-prompt-ts

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

email-prompt-ts

CLI email prompt with autocompletion and built-in validation

0.3.2
latest
Source
npmnpm
Version published
Weekly downloads
1.9K
-8.48%
Maintainers
1
Weekly downloads
 
Created
Source

email-prompt

Build Status XO code style Slack Channel

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

prompt

Usage

import emailPrompt from 'email-prompt'

let email

try {
  email = await emailPrompt({ /* options */ })
} catch (err) {
  console.log('\n> Aborted!')
  return
}

console.log('\n> Hello ' + email)

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
    • icloud.com
    • zeit.co
  • 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.

Authors

FAQs

Package last updated on 15 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts