{"_id":"prompt-lite","_rev":"11-aada687536ccba778d4ead5c1b965ea2","name":"prompt-lite","description":"A simpler command-line prompt for node.js","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"prompt-lite","description":"A simpler command-line prompt for node.js","version":"0.1.0","author":{"name":"Joshua Holbrook"},"maintainers":[{"name":"jesusabdullah","email":"josh.holbrook@gmail.com"}],"repository":{"type":"git","url":"http://github.com/jesusabdullah/prompt-lite.git"},"dependencies":{"read":"1.0.x","revalidator":"0.1.x","colors":"0.6.x","async":"~0.1.22"},"devDependencies":{"vows":"0.7.0"},"main":"./lib/prompt","scripts":{"test":"vows test/prompt-test.js --spec","test-all":"vows --spec"},"engines":{"node":">= 0.6.6"},"_id":"prompt-lite@0.1.0","dist":{"shasum":"b7e65a2f9e01548574b0302b8bd618c566e42236","tarball":"https://registry.npmjs.org/prompt-lite/-/prompt-lite-0.1.0.tgz","integrity":"sha512-DxS7Ar9YvFOyx+V26XtOHyfLqvQbFuDexSYwwZIWAZZhBZ0jog93B+s1KBSwJRkng6SAtVrK+UoiPW9Z/K8vaQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDGGmBAqGgIbV3+udTyR/tFa2fVucXs0ktEsgGJ6Bm2BAiBsBWXypDueL4HttE3yi2PSdxOZEAscmVjoQPmPgUuwqg=="}]},"_npmVersion":"1.2.0","_npmUser":{"name":"jesusabdullah","email":"josh.holbrook@gmail.com"},"directories":{},"deprecated":"promit-lite is deprecated in favor of @jfhbrook/prompt."},"0.1.1":{"name":"prompt-lite","description":"A simpler command-line prompt for node.js","version":"0.1.1","author":{"name":"Joshua Holbrook"},"maintainers":[{"name":"jesusabdullah","email":"josh.holbrook@gmail.com"}],"repository":{"type":"git","url":"http://github.com/jesusabdullah/prompt-lite.git"},"dependencies":{"read":"1.0.x","revalidator":"0.1.x","colors":"0.6.x","async":"~0.1.22"},"devDependencies":{"vows":"0.7.0"},"main":"./lib/prompt","scripts":{"test":"vows test/prompt-test.js --spec","test-all":"vows --spec"},"engines":{"node":">= 0.6.6"},"_id":"prompt-lite@0.1.1","dist":{"shasum":"fa848f81ba139e7d3f321773ddafc93d32857c75","tarball":"https://registry.npmjs.org/prompt-lite/-/prompt-lite-0.1.1.tgz","integrity":"sha512-G9Gvrl8MDffhHOF+9+VznrGdF5rnk0rr5xpDAzc9AThYy4X/dH7Bnd/x7/HYdeWPT5VilKZXW6W2g88esqAfIQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH1LT4du0XtqrHgPUCtzQ42u414ac/utwOskRI0Vo1PFAiAdigQzanPo2VSnkHTKAfLHDAtC7Bpo+iUzHBvs3E5Mbw=="}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"jesusabdullah","email":"josh.holbrook@gmail.com"},"directories":{},"deprecated":"promit-lite is deprecated in favor of @jfhbrook/prompt."}},"readme":"# prompt-lite\n\nA fork of Nodejitsu's beautiful command-line prompt for node.js with a smaller dependency tree.\n\n## Features\n\n* prompts the user for input\n* supports validation and defaults\n* hides passwords\n\n## Usage\nUsing prompt is relatively straight forward. There are two core methods you should be aware of: `prompt.get()` and `prompt.addProperties()`. There methods take strings representing property names in addition to objects for complex property validation (and more). There are a number of [examples][0] that you should examine for detailed usage.\n\n### Getting Basic Prompt Information\nGetting started with `prompt` is easy. Lets take a look at `examples/simple-prompt.js`:\n\n``` js\n  var prompt = require('prompt');\n\n  //\n  // Start the prompt\n  //\n  prompt.start();\n\n  //\n  // Get two properties from the user: username and email\n  //\n  prompt.get(['username', 'email'], function (err, result) {\n    //\n    // Log the results.\n    //\n    console.log('Command-line input received:');\n    console.log('  username: ' + result.username);\n    console.log('  email: ' + result.email);\n  });\n```\n\nThis will result in the following command-line output:\n\n```\n  $ node examples/simple-prompt.js \n  prompt: username: some-user\n  prompt: email: some-user@some-place.org\n  Command-line input received:\n    username: some-user\n    email: some-user@some-place.org\n```\n\n### Prompting with Validation, Default Values, and More (Complex Properties)\nIn addition to prompting the user with simple string prompts, there is a robust API for getting and validating complex information from a command-line prompt. Here's a quick sample:\n\n``` js\n  var schema = {\n    properties: {\n      name: {\n        pattern: /^[a-zA-Z\\s\\-]+$/,\n        message: 'Name must be only letters, spaces, or dashes',\n        required: true\n      },\n      password: {\n        hidden: true\n      }\n    }\n  };\n\n  //\n  // Start the prompt\n  //\n  prompt.start();\n\n  //\n  // Get two properties from the user: email, password\n  //\n  prompt.get(schema, function (err, result) {\n    //\n    // Log the results.\n    //\n    console.log('Command-line input received:');\n    console.log('  name: ' + result.name);\n    console.log('  password: ' + result.password);\n  });\n```\n\nPretty easy right? The output from the above script is: \n\n```\n  $ node examples/property-prompt.js\n  prompt: name: nodejitsu000\n  error:  Invalid input for name\n  error:  Name must be only letters, spaces, or dashes\n  prompt: name: Nodejitsu Inc\n  prompt: password: \n  Command-line input received:\n    name: Nodejitsu Inc\n    password: some-password  \n```\n\n## Valid Property Settings\n`prompt` understands JSON-schema with a few extra parameters and uses [revalidator](https://github.com/flatiron/revalidator) for validation.\n\nHere's an overview of the properties that may be used for validation and prompting controls:\n\n``` js\n  {\n    description: 'Enter your password',     // Prompt displayed to the user. If not supplied name will be used.\n    type: 'string',                 // Specify the type of input to expect.\n    pattern: /^\\w+$/,                  // Regular expression that input must be valid against.\n    message: 'Password must be letters', // Warning message to display if validation fails.\n    hidden: true,                        // If true, characters entered will not be output to console.\n    default: 'lamepassword',             // Default value to use if no value is entered.\n    required: true                        // If true, value entered must be non-empty.\n    before: function(value) { return 'v' + value; } // Runs before node-prompt callbacks. It modifies user's input\n  }\n```\n\nAlternatives to `pattern` include `format` and `conform`, as documented in [revalidator](https://github.com/flatiron/revalidator).\n\nUsing `type: 'array'` has some special cases.\n\n- `description` will not work in the schema if `type: 'array'` is defined.\n- `maxItems` takes precedence over `minItems`.\n- Arrays that do not have `maxItems` defined will require users to `SIGINT` (`^C`) before the array is ended.\n- If `SIGINT` (`^C`) is triggered before `minItems` is met, a validation error will appear. This will require users to `SIGEOF` (`^D`) to end the input.\n\nFor more information on things such as `maxItems` and `minItems`, refer to the [revalidator](https://github.com/flatiron/revalidator) repository.\n\n### Alternate Validation API:\n\nPrompt, in addition to iterating over JSON-Schema properties, will also happily iterate over an array of validation objects given an extra 'name' property:\n\n```js\n  var prompt = require('../lib/prompt');\n\n  //\n  // Start the prompt\n  //\n  prompt.start();\n\n  //\n  // Get two properties from the user: username and password\n  //\n  prompt.get([{\n      name: 'username',\n      required: true\n    }, {\n      name: 'password',\n      hidden: true,\n      conform: function (value) {\n        return true;\n      }\n    }], function (err, result) {\n    //\n    // Log the results.\n    //\n    console.log('Command-line input received:');\n    console.log('  username: ' + result.username);\n    console.log('  password: ' + result.password);\n  });\n```\n\n### Backward Compatibility\n\nNote that, while this structure is similar to that used by prompt 0.1.x, that the object properties use the same names as in JSON-Schema. prompt 0.2.x is backward compatible with prompt 0.1.x except for asynchronous validation.\n\n### Skipping Prompts\n\nSometimes power users may wish to skip promts and specify all data as command line options. \nif a value is set as a property of `prompt.override` prompt will use that instead of \nprompting the user.\n\n``` js\n  //prompt-override.js\n\n  var prompt = require('prompt'),\n      optimist = require('optimist')\n\n  //\n  // set the overrides\n  //\n  prompt.override = optimist.argv\n\n  //\n  // Start the prompt\n  //\n  prompt.start();\n\n  //\n  // Get two properties from the user: username and email\n  //\n  prompt.get(['username', 'email'], function (err, result) {\n    //\n    // Log the results.\n    //\n    console.log('Command-line input received:');\n    console.log('  username: ' + result.username);\n    console.log('  email: ' + result.email);\n  })\n\n  //: node prompt-override.js --username USER --email EMAIL\n```\n\n\n### Adding Properties to an Object \nA common use-case for prompting users for data from the command-line is to extend or create a configuration object that is passed onto the entry-point method for your CLI tool. `prompt` exposes a convenience method for doing just this: \n\n``` js\n  var obj = {\n    password: 'lamepassword',\n    mindset: 'NY'\n  }\n\n  //\n  // Log the initial object.\n  //\n  console.log('Initial object to be extended:');\n  console.dir(obj);\n\n  //\n  // Add two properties to the empty object: username and email\n  //\n  prompt.addProperties(obj, ['username', 'email'], function (err) {\n    //\n    // Log the results.\n    //\n    console.log('Updated object received:');\n    console.dir(obj);\n  });\n```\n\n## Customizing your prompt\nAside from changing `property.message`, you can also change `prompt.message`\nand `prompt.delimiter` to change the appearance of your prompt.\n\nThe basic structure of a prompt is this:\n\n``` js\nprompt.message + prompt.delimiter + property.message + prompt.delimiter;\n```\n\nThe default `prompt.message` is \"prompt,\" the default `prompt.delimiter` is\n\": \", and the default `property.message` is `property.name`.\nChanging these allows you to customize the appearance of your prompts! In\naddition, prompt supports ANSI color codes via the\n[colors module](https://github.com/Marak/colors.js) for custom colors. For a\nvery colorful example:\n\n``` js\n  var prompt = require(\"prompt\");\n\n  //\n  // Setting these properties customizes the prompt.\n  //\n  prompt.message = \"Question!\".rainbow;\n  prompt.delimiter = \"><\".green;\n\n  prompt.start();\n\n  prompt.get({\n    properties: {\n      name: {\n        description: \"What is your name?\".magenta\n      }\n    }\n  }, function (err, result) {\n    console.log(\"You said your name is: \".cyan + result.name.cyan);\n  });\n```\n\nIf you don't want colors, you can set\n\n```js\nvar prompt = require('prompt');\n\nprompt.colors = false;\n```\n\n## Installation\n\n``` bash\n  $ [sudo] npm install prompt\n```\n\n## Running tests\n\n``` bash \n  $ npm test\n```\n\n#### License: MIT\n\n[0]: https://github.com/flatiron/prompt/tree/master/examples\n","maintainers":[{"email":"josh.holbrook@gmail.com","name":"jesusabdullah"}],"time":{"modified":"2022-06-24T19:54:15.097Z","created":"2013-01-27T15:55:55.436Z","0.1.0":"2013-01-27T15:56:10.183Z","0.1.1":"2013-04-01T00:52:15.607Z"},"author":{"name":"Joshua Holbrook"},"repository":{"type":"git","url":"http://github.com/jesusabdullah/prompt-lite.git"},"readmeFilename":"README.md"}