Inquirer Development Tutorials, Guides & Insights
Unlock 1+ expert-curated inquirer tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your inquirer skills on DeveloperBreeze.
Adblocker Detected
It looks like you're using an adblocker. Our website relies on ads to keep running. Please consider disabling your adblocker to support us and access the content.
Tutorial
javascript nodejs
Crafting Beautiful CLI Tools with Node.js: Make Command-Line Interfaces Fun
const inquirer = require('inquirer');
yargs.command({
command: 'create',
describe: 'Create a new file',
handler() {
inquirer.prompt([
{
type: 'input',
name: 'filename',
message: 'Enter the file name:'
},
{
type: 'list',
name: 'extension',
message: 'Choose a file extension:',
choices: ['.js', '.txt', '.md']
}
]).then(answers => {
console.log(chalk.blue(`Creating file: ${answers.filename}${answers.extension}`));
// Add your file creation logic here
});
}
});
yargs.parse();This code adds a create command that prompts the user to enter a filename and select a file extension. The results are then displayed with a styled message.
Aug 20, 2024
Read More