Skip to content

Commit

Permalink
using a test for yargs/yargs#2114
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdugne committed Jan 13, 2022
1 parent a6f0ccf commit 5724753
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions cli/test-cli.js
@@ -0,0 +1,26 @@
#!/usr/bin/env node
// -----------------------------------------------------------------------------

const yargs = require('yargs');
const inquirer = require('inquirer');

const sing = () => console.log('🎵 Oy oy oy');

const askName = async () => {
const answers = await inquirer.prompt([
{
message: 'What is your name?',
name: 'name',
type: 'string'
}
]);

console.log(`Hello, ${answers.name}!`);
};

const argv = yargs(process.argv.splice(2))
.command('ask', 'use inquirer to prompt for your name', () => {}, askName)
.command('sing', 'a classic yargs command without prompting', () => {}, sing)
.demandCommand(1, 1, 'choose a command: ask or sing')
.strict()
.help('h').argv;

0 comments on commit 5724753

Please sign in to comment.