email-prompt

    0.4.0 • Public • Published

    email-prompt

    CLI email prompt featuring autocompletion and validation. Powers vercel --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
      • hey.com
      • zeit.co
      • vercel.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.

    Authors

    Keywords

    none

    Install

    npm i email-prompt

    DownloadsWeekly Downloads

    1,138

    Version

    0.4.0

    License

    MIT

    Unpacked Size

    8.38 kB

    Total Files

    4

    Last publish

    Collaborators

    • codetaromiura
    • redacted-vercel
    • gkaragkiaouris
    • geovanisouza92
    • dglsparsons
    • lostinpatterns
    • vercel-release-bot
    • southpolesteve
    • matheuss
    • igorklopov
    • leo
    • nkzawa
    • tootallnate
    • rauchg
    • timneutkens
    • javivelasco
    • iamevilrabbit
    • kdy1
    • joecohens
    • quietshu
    • dav-is
    • styfle
    • zeit-bot
    • lucleray
    • mglagola
    • andybitz
    • paulogdm
    • anatrajkovska
    • timer
    • umegaya
    • arzafran
    • ijjk
    • mfix22
    • lfades
    • rabaut
    • msweeneydev
    • williamli
    • ragojose
    • guybedford
    • paco
    • skllcrn
    • janicklas-ralph
    • atcastle
    • keanulee
    • spanicker
    • developit
    • housseindjirdeh
    • gmonaco
    • kikobeats
    • prateekbh
    • jkrems
    • jaredpalmer
    • gielcobben
    • chibicode
    • nazarenooviedo
    • samsisle
    • okbel
    • hankvercel
    • leerobinson
    • elsigh
    • julianbenegas
    • rizbizkits
    • raunofreiberg
    • sokra
    • cl3arglass
    • chriswdmr
    • ernestd
    • ismaelrumzan
    • jhoch
    • mitchellwright
    • mrmckeb
    • kuvos
    • creationix
    • aboodman
    • huozhi
    • cmvnk
    • arv
    • ktcarter
    • padmaia
    • delba
    • catsaremlg
    • steventey
    • gsandhu
    • dbredvick