CLI email prompt with autocompletion and built-in validation
MIT License
CLI email prompt featuring autocompletion and validation.
Powers vercel --login
.
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
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:
resolveChars
(Set
): a set of chars that resolve the promise. Defaults to ↵returnabortChars
(Set
): a set of chars that abort the process. Defaults to Ctrl+CallowInvalidChars
(Boolean
): controls whether non-email chars are accepted. Defaults to false
Some important implementation details:
email-prompt
automatically adapts the mode of process.stdin
for you.stdin
stream is resume
d and pause
d upon the promise beingtty
mode is set to raw
, which means all the caret interactionsstdin
prompt are simulated.