87 lines
5.0 KiB
JSON
87 lines
5.0 KiB
JSON
{
|
|
"_args": [
|
|
[
|
|
{
|
|
"raw": "yesno@^0.0.1",
|
|
"scope": null,
|
|
"escapedName": "yesno",
|
|
"name": "yesno",
|
|
"rawSpec": "^0.0.1",
|
|
"spec": ">=0.0.1 <0.0.2",
|
|
"type": "range"
|
|
},
|
|
"/home/jdaugherty/work/GT2/GT2-Android/node_modules/xdl"
|
|
]
|
|
],
|
|
"_from": "yesno@>=0.0.1 <0.0.2",
|
|
"_id": "yesno@0.0.1",
|
|
"_inCache": true,
|
|
"_location": "/yesno",
|
|
"_npmUser": {
|
|
"name": "tcql",
|
|
"email": "tim.channell@gmail.com"
|
|
},
|
|
"_npmVersion": "1.2.11",
|
|
"_phantomChildren": {},
|
|
"_requested": {
|
|
"raw": "yesno@^0.0.1",
|
|
"scope": null,
|
|
"escapedName": "yesno",
|
|
"name": "yesno",
|
|
"rawSpec": "^0.0.1",
|
|
"spec": ">=0.0.1 <0.0.2",
|
|
"type": "range"
|
|
},
|
|
"_requiredBy": [
|
|
"/xdl"
|
|
],
|
|
"_resolved": "https://registry.npmjs.org/yesno/-/yesno-0.0.1.tgz",
|
|
"_shasum": "ffbc04ff3d6f99dad24f7463134e9b92ae41bef6",
|
|
"_shrinkwrap": null,
|
|
"_spec": "yesno@^0.0.1",
|
|
"_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/xdl",
|
|
"author": {
|
|
"name": "Tim Channell"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/tchannel/node-yesno/issues"
|
|
},
|
|
"dependencies": {},
|
|
"description": "A simple library for asking boolean questions in cli programs",
|
|
"devDependencies": {},
|
|
"directories": {},
|
|
"dist": {
|
|
"shasum": "ffbc04ff3d6f99dad24f7463134e9b92ae41bef6",
|
|
"tarball": "https://registry.npmjs.org/yesno/-/yesno-0.0.1.tgz"
|
|
},
|
|
"homepage": "https://github.com/tchannel/node-yesno#readme",
|
|
"keywords": [
|
|
"cli",
|
|
"confirm",
|
|
"yesno",
|
|
"yes or no",
|
|
"prompt",
|
|
"question"
|
|
],
|
|
"license": "BSD",
|
|
"main": "yesno.js",
|
|
"maintainers": [
|
|
{
|
|
"name": "tcql",
|
|
"email": "tim.channell@gmail.com"
|
|
}
|
|
],
|
|
"name": "yesno",
|
|
"optionalDependencies": {},
|
|
"readme": "### Intro\r\n\r\nyesno is a super simple nodejs library for issuing and handling responses to boolean (or rather, binary) questions \r\n\r\n\r\n### Installation\r\n\r\n npm install yesno\r\n\r\nOr point your package.json at the latest version of yesno\r\n\r\n\r\n### Usage\r\n\r\nThe usage of **ask** is as follows:\r\n\r\n ask(\r\n <string> question, \r\n <boolean|null> default_value,\r\n <function> response_handler,\r\n <array|null> yes_values,\r\n <array|null> no_values\r\n )\r\n\r\nIf yes_values or no_values aren't supplied, yesno falls back on accepting \"yes\" or \"y\" and \"no\" or \"n\".\r\n\r\nyesno handles all responses case insensitively.\r\n\r\nHere's an example:\r\n\r\n var yesno = require('yesno');\r\n\r\n yesno.ask('Are you sure you want to continue?', true, function(ok) {\r\n if(ok) {\r\n console.log(\"Yay!\");\r\n } else {\r\n console.log(\"Nope.\");\r\n }\r\n });\r\n\r\n\r\n\r\n\r\n\r\n### Examples\r\n\r\n##### Custom Yes/No response values\r\n\r\n var yesno = require('yesno');\r\n\r\n yesno.ask('Dude, Is this groovy or what?',true, function(ok) {\r\n if(ok) {\r\n console.log(\"Tubular.\");\r\n } else {\r\n console.log(\"Aw, why you gotta be like that?\")\r\n }\r\n }, ['groovy'],['or what']);\r\n\r\nNow the question only responds to \"groovy\" as yes and \"or what\" as no.\r\n\r\n\r\n\r\n##### No default value\r\n\r\nSometimes you may want to ensure the user didn't accidentally accept a default. You can disable the default response by passing null as the default_value parameter\r\n\r\n var yesno = require('yesno');\r\n\r\n var handleResponse = function(ok) {\r\n ...\r\n };\r\n\r\n yesno.ask(\"Are you sure you want to 'rm-rf /' ?\", null, handleResponse);\r\n\r\n\r\n##### Globally changing Yes/No respones values\r\n\r\nYou can change the built in yes/no accepted responses by altering yesno's options attribute:\r\n\r\n var yesno = require('yesno');\r\n\r\n yesno.options.yes = ['ja','si'];\r\n yesno.options.no = ['nein','no'];\r\n\r\n\r\n##### Handling invalid responses\r\n\r\nBy default, if the user enters a value that isn't recognized as an acceptable response, it will\r\nprint out a message like: \r\n\r\n Invalid response.\r\n Answer either yes : (yes, y)\r\n Or no : (no, n)\r\n\r\nand re-ask the question. If you want to change this behavior, you can set the invalid handler before asking your question:\r\n\r\n var yesno = require('yesno');\r\n\r\n yesno.onInvalidHandler(function (question, default_value, callback, yes_values, no_values) {\r\n process.stdout.write(\"\\n Whoa. That was not a good answer. Well. No more tries for you.\");\r\n process.exit(1);\r\n });\r\n\r\n // ask a question\r\n\r\n\r\n### Future / Todo\r\n\r\n- Allow supplying your own stdin/stdout streams so it doesn't always write to the process?\r\n- Put in some error handling\r\n- Tests",
|
|
"readmeFilename": "README.md",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/tchannel/node-yesno.git"
|
|
},
|
|
"scripts": {
|
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
},
|
|
"version": "0.0.1"
|
|
}
|