2.0.1 • Published 7 years ago
@creuna/prompt v2.0.1
prompt
Node module for getting user input in shell
Install
yarn add @creuna/promptUsage
prompt(questions: Object) : Object
const { name, likesPrompt } = prompt({
name: "Your name",
age: {
text: "Your age",
value: process.argv[2],
optional: true
},
password: {
text: "Password",
obfuscate: true
},
likesPrompt: {
text: "Do you like prompt?",
type: Boolean
}
});Question
Question can either be a string or an object. If question is a string, all config options will have the default value. If you need to configure the question, pass it as an object
Question config
- text:
string. Text to display to user - value:
stringorboolean. Predefined answer to question. If it is defined, prompt will not ask this question. Great for usage with process.argv. - type:
String | Boolean- defaultString. If Boolean is used, 'y/n' will be printed behind the text, and the answer will be returned as a boolean - obfuscate:
boolean- defaultfalse. If set totrue, input will be obfuscated with asterisks (***) - optional:
Boolean- defaultfalse. Affects questions of typeStringonly. If set totrue, a missing answer will be returned as an empty string. If left atfalse, prompt will keep asking until a non-empty answer is given.