-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(prompt): Add the 'if-empty' value to the prompt option (closes #8)…
… (#9) BREAKING CHANGE: this feature breaks the contract of the prompt property, changing it from a boolean to a string.
- Loading branch information
1 parent
4319a5a
commit 2bf8ed6
Showing
15 changed files
with
3,002 additions
and
150 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.npm | ||
.DS_Store | ||
.nyc_output | ||
coverage | ||
npm-debug.log | ||
node_modules | ||
build | ||
|
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
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
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
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
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,39 @@ | ||
#!/usr/bin/env node | ||
|
||
/* | ||
* Usage 1: | ||
* 1) Open a terminal. | ||
* 2) Enter: node ./examples/prompt.js --interactive | ||
* Result: The tool will prompt question for namem and likesPizza. | ||
* | ||
* Usage 2: | ||
* 1) Open a terminal. | ||
* 2) Enter: node ./examples/prompt.js --name="John" | ||
* Result: The tool will prompt question for likesPizza but not for the name (it was sent via parameter). | ||
*/ | ||
|
||
const yargsInteractive = require('../src'); | ||
|
||
const options = { | ||
name: { | ||
type: 'input', | ||
describe: 'Enter your name', | ||
prompt: 'if-empty' | ||
}, | ||
likesPizza: { | ||
type: 'confirm', | ||
default: false, | ||
describe: 'Do you like pizza?' | ||
}, | ||
}; | ||
|
||
yargsInteractive() | ||
.usage('$0 <command> [args]') | ||
.interactive(options) | ||
.then((result) => { | ||
console.log( | ||
`\nResult is:\n` | ||
+ `- Name: ${result.name}\n` | ||
+ `- Likes pizza: ${result.likesPizza}\n` | ||
); | ||
}); |
Oops, something went wrong.