From a0a47e8141fb4254226952d2ae68607ee5223f47 Mon Sep 17 00:00:00 2001 From: Gangstead Date: Mon, 8 Feb 2016 11:08:52 -0600 Subject: [PATCH] updated color example and major revision bump for breaking color change --- README.md | 34 +++++++++++++++++----------------- examples/color.js | 19 +++++++++++++++++++ package.json | 2 +- 3 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 examples/color.js diff --git a/README.md b/README.md index 1d7ce28..0da2184 100644 --- a/README.md +++ b/README.md @@ -313,25 +313,25 @@ addition, prompt supports ANSI color codes via the very colorful example: ``` js - var prompt = require("prompt"); - - // - // Setting these properties customizes the prompt. - // - prompt.message = "Question!".rainbow; - prompt.delimiter = "><".green; +var prompt = require("../lib/prompt"); +var colors = require("colors/safe"); +// +// Setting these properties customizes the prompt. +// +prompt.message = colors.rainbow("Question!"); +prompt.delimiter = colors.green("><"); - prompt.start(); +prompt.start(); - prompt.get({ - properties: { - name: { - description: "What is your name?".magenta - } +prompt.get({ + properties: { + name: { + description: colors.magenta("What is your name?") } - }, function (err, result) { - console.log("You said your name is: ".cyan + result.name.cyan); - }); + } +}, function (err, result) { + console.log(colors.cyan("You said your name is: " + result.name)); +}); ``` If you don't want colors, you can set @@ -355,7 +355,7 @@ test_prompt(_); ``` This will work, however the process is then stuck with a stdin stream still open. If you setup the traditional way (with callback) such as this - + ``` prompt.start(); function test_prompt(){ diff --git a/examples/color.js b/examples/color.js new file mode 100644 index 0000000..7c63112 --- /dev/null +++ b/examples/color.js @@ -0,0 +1,19 @@ +var prompt = require("../lib/prompt"); +var colors = require("colors/safe"); +// +// Setting these properties customizes the prompt. +// +prompt.message = colors.rainbow("Question!"); +prompt.delimiter = colors.green("><"); + +prompt.start(); + +prompt.get({ + properties: { + name: { + description: colors.magenta("What is your name?") + } + } +}, function (err, result) { + console.log(colors.cyan("You said your name is: " + result.name)); +}); diff --git a/package.json b/package.json index a521e97..95da4c3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "prompt", "description": "A beautiful command-line prompt for node.js", - "version": "0.3.0", + "version": "1.0.0", "author": "Nodejitsu Inc. ", "maintainers": [ "indexzero ",