1.0.0 • Published 10 years ago
@unumux/autorelease-test v1.0.0
UX-Questions
A library for creating CLI questions using Inquirer Promisify
yesNo(question, defaultAns) => promise
Ask a yes or no question
Parameters
| Name | Type | Description |
|---|---|---|
| question | string | "Do you like cheese?" |
| defaultAns | boolean | default = true |
Returns
| Type | Description |
|---|---|
| promise | The user's answer {boolean} if fulfilled, or an error if rejected. |
Examples
// returns user's answer as boolean or default answer
yesNo("Do you like cheese?");
// returns user's answer as boolean or default answer
yesNo("Do you hate cheese?", false);Source: index.js, line: 24
text(question, defaultAns) => promise
Ask an open-ended question
Parameters
| Name | Type | Description |
|---|---|---|
| question | string | "What's your name?" |
| defaultAns | string | default = null |
Returns
| Type | Description |
|---|---|
| promise | The user's answer {string} if fulfilled, or an error if rejected. |
Examples
// returns user's answer as string or default answer
text("What is your name?");Source: index.js, line: 44
password(question, defaultAns) => promise
Ask for a password
Parameters
| Name | Type | Description |
|---|---|---|
| question | string | "What's your password?" |
| defaultAns | string | default = null |
Returns
| Type | Description |
|---|---|
| promise | The user's answer {string} if fulfilled, or an error if rejected. |
Examples
//returns user's answer as string or default answer
password("What is your password?");Source: index.js, line: 61
list(question, choices, defaultAns) => promise
Ask a question with multiple choices that accepts one answer
Parameters
| Name | Type | Description |
|---|---|---|
| question | string | "Which of these is your favorite color? (mark all that apply)" |
| choices | array | "red", "blue", "yellow" |
| defaultAns | string | default = array0 |
Returns
| Type | Description |
|---|---|
| promise | The user's answer {string} if fulfilled, or an error if rejected. |
Examples
//returns user's answer as string or default answer
list("Which is your favorite color?", ["red", "blue", "yellow"]);Source: index.js, line: 78
checkbox(question, choices) => promise
Ask a question with multiple choices that accepts one or more answers
Parameters
| Name | Type | Description |
|---|---|---|
| question | string | "Which one of these is your favorite color?" |
| choices | array | "red", "blue", "yellow" |
Returns
| Type | Description |
|---|---|
| promise | The user's answer(s) {array of strings} if fulfilled, or an error if rejected. |
Examples
//returns user's answer(s) as an array of strings
checkbox("Which places have you visited?", ["Columbia, SC", "Charlotte, NC", "Manchester, England"]);Source: index.js, line: 97