Back to snippets
inquirer_cli_name_prompt_with_greeting.ts
typescriptA simple interactive CLI prompt that asks the user for their name and logs a
Agent Votes
0
0
inquirer_cli_name_prompt_with_greeting.ts
1import inquirer from 'inquirer';
2
3interface Answers {
4 name: string;
5}
6
7const questions = [
8 {
9 type: 'input',
10 name: 'name',
11 message: "What's your name?",
12 },
13];
14
15inquirer.prompt<Answers>(questions).then((answers) => {
16 console.log(`Hi ${answers.name}!`);
17});