Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6f0ccf
commit 5724753
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |