Comparing version 0.3.0 to 1.0.0
@@ -11,3 +11,3 @@ var QA = require('./'); | ||
{ title: "{yellow}Favorite {green}Fruits{reset}:", commaList: true }, | ||
{ key: 'thatsAll', title: "{yellow}{bold}That's all {grey}(yes/no) {yellow}?{reset}", bool: true }, | ||
{ key: 'thatsAll', title: "{yellow}{bold}That's all, {name}? {grey}(yes/no){reset}", bool: true }, | ||
]; | ||
@@ -14,0 +14,0 @@ |
24
index.js
var read = require("read-cli-input"); | ||
var loop = require("serial-loop"); | ||
var format = require("style-format"); | ||
var style = require("style-format"); | ||
var variable = require("variable-name"); | ||
var leftpad = require("left-pad"); | ||
var validate = require("validate-value"); | ||
var format = require("format-text"); | ||
@@ -22,2 +23,3 @@ module.exports = QA; | ||
var answers = {}; | ||
options.answers = answers; | ||
@@ -37,3 +39,3 @@ loop(questions.length, each, function () { | ||
function ask (question, options, callback) { | ||
options.stdout.write(formatQuestion(question)); | ||
options.stdout.write(format(styleQuestion(question), options.answers)); | ||
@@ -61,3 +63,3 @@ var readOptions = { | ||
if (question.validate && (err = validate(answer, question.validate))) { | ||
options.stdout.write(formatError(err)); | ||
options.stdout.write(styleError(err)); | ||
return ask(question, options, callback); | ||
@@ -78,3 +80,3 @@ } | ||
return function (line) { | ||
options.stdout.write(formatPrefix(line, options)); | ||
options.stdout.write(stylePrefix(line, options)); | ||
}; | ||
@@ -113,3 +115,3 @@ } | ||
if (!question.key) { | ||
question.key = variable(clearFormat(question.title)); | ||
question.key = variable(clearFormatting(question.title)); | ||
} | ||
@@ -120,9 +122,9 @@ | ||
function formatQuestion (question) { | ||
function styleQuestion (question) { | ||
return ' ' | ||
+ format(question.title) | ||
+ style(question.title) | ||
+ (question.list ? '\n' : ' '); | ||
} | ||
function formatPrefix (line, options) { | ||
function stylePrefix (line, options) { | ||
if (options.prefix) return options.prefix(line); | ||
@@ -132,3 +134,3 @@ return ' ' + (line + 1) + '. '; | ||
function clearFormat (text) { | ||
function clearFormatting (text) { | ||
return text.replace(/\{\w+\}/g, ''); | ||
@@ -141,4 +143,4 @@ } | ||
function formatError (err) { | ||
return format('\n {red}{bold}Error: ' + err.message + '{reset}\n'); | ||
function styleError (err) { | ||
return style('\n {red}{bold}Error: ' + err.message + '{reset}\n'); | ||
} |
{ | ||
"name": "cli-qa", | ||
"version": "0.3.0", | ||
"version": "1.0.0", | ||
"description": "Command-line Questions & Answers", | ||
@@ -26,2 +26,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"format-text": "0.0.3", | ||
"left-pad": "0.0.4", | ||
@@ -28,0 +29,0 @@ "read-cli-input": "1.0.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6251
125
1
7
+ Addedformat-text@0.0.3
+ Addedformat-text@0.0.3(transitive)
- Removedformat-text@2.0.0(transitive)