Created
June 25, 2020 11:13
-
-
Save kenanchristian/5ee0a9ad4d8363de3ddb6cf5138c6d4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { prompt } from 'inquirer' | |
... | |
async run() { | |
const userInput = prompt([ | |
{ | |
type: 'number', | |
name: 'count', | |
message: 'How many pizza you want to create', | |
default: 1, | |
validate(value) { | |
if (isNaN(parseInt(value, 10))) { | |
return 'Pizza count should be a number' | |
} | |
return true | |
}, | |
}, | |
{ | |
type: 'list', | |
name: 'crust', | |
message: 'How do you want you pizza crust be?', | |
default: 'Thin', | |
choices: ['Thin', 'Thick'], | |
}, | |
{ | |
type: 'checkbox', | |
name: 'toppings', | |
message: 'What do you want to add as toppings?', | |
default: '', | |
choices: [ | |
{ | |
name: '🍖 Pepperoni', | |
value: 'pepperoni', | |
}, | |
{ | |
name: '🍄 Mushroom', | |
value: 'mushroom', | |
}, | |
{ | |
name: '🥓 Bacon', | |
value: 'bacon', | |
}, | |
{ | |
name: '🍍 Pineapple', | |
value: 'pineapple', | |
}, | |
], | |
validate(value) { | |
if (value.length === 0) { | |
return 'You should add at least 1 topping' | |
} | |
return true | |
}, | |
}, | |
{ | |
type: 'confirm', | |
name: 'extraSauce', | |
message: 'Do you want extra sauce?', | |
default: false, | |
}, | |
]) | |
this.log(JSON.stringify(userInput)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment