Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make config help look better

  • Loading branch information...
commit b69b4b9a1637f3a91c412b4461be17a5aaff9452 1 parent 9aafc2a
@gotwarlost authored
Showing with 26 additions and 14 deletions.
  1. +19 −13 lib/command/help.js
  2. +7 −1 lib/util/help-formatter.js
View
32 lib/command/help.js
@@ -8,25 +8,31 @@ var Command = require('./index.js'),
formatOption = require('../util/help-formatter').formatOption,
VERSION = require('../../index').VERSION,
configuration = require('../configuration'),
- yaml = require('js-yaml');
+ yaml = require('js-yaml'),
+ formatPara = require('../util/help-formatter').formatPara;
function showConfigHelp(toolName) {
console.error('\nConfiguring ' + toolName);
console.error('====================');
- console.error('\n' + toolName + ' can be configured globally using a .istanbul.yml YAML file at the root of your source tree');
- console.error('\nEvery command also accepts a --config=<config-file> argument to customize its location per command');
- console.error('The alternate config file can be in YAML, JSON or node.js (exporting the config object).');
- console.error('\nThe config file currently has three sections for instrumentation, reporting and hooks.');
- console.error('Note that certain commands (like cover) use information from multiple sections.');
- console.error('\nKeys in the config file usually correspond to command line parameters with the same name');
- console.error('The verbose option for every command shows you the exact configuration used');
- console.error('\nThe default configuration is as follows:\n');
+ console.error('\n' +
+ formatPara(toolName + ' can be configured globally using a .istanbul.yml YAML file ' +
+ 'at the root of your source tree. Every command also accepts a --config=<config-file> argument to ' +
+ 'customize its location per command. The alternate config file can be in YAML, JSON or node.js ' +
+ '(exporting the config object).'));
+ console.error('\n' +
+ formatPara('The config file currently has three sections for instrumentation, reporting and hooks. ' +
+ 'Note that certain commands (like `cover`) use information from multiple sections.'));
+ console.error('\n' +
+ formatPara('Keys in the config file usually correspond to command line parameters with the same name. ' +
+ 'The verbose option for every command shows you the exact configuration used'));
+ console.error('\nThe default configuration is as follows:\n');
console.error(yaml.safeDump(configuration.defaultConfig(), { indent: 4, flowLevel: 3 }));
- console.error('\nThe `watermarks` section does not have a command line equivalent');
- console.error('This allows you to set up low and high watermark percentages for reporting');
- console.error('These are honored by all reporters that colorize their output based on low/ medium/ high coverage');
+ console.error('\n' +
+ formatPara('The `watermarks` section does not have a command line equivalent. It allows you to set up ' +
+ 'low and high watermark percentages for reporting. These are honored by all reporters that colorize ' +
+ 'their output based on low/ medium/ high coverage'));
}
function HelpCommand() {
@@ -44,7 +50,7 @@ Command.mix(HelpCommand, {
usage: function () {
console.error('\nUsage: ' + this.toolName() + ' ' + this.type() + ' config | <command>\n');
- console.error('config provides help with istanbul configuration\n');
+ console.error('`config` provides help with istanbul configuration\n');
console.error('Available commands are:\n');
var commandObj;
View
8 lib/util/help-formatter.js
@@ -7,7 +7,12 @@ var OPT_PREFIX = " ",
OPT_START = OPT_PREFIX.length,
TEXT_START = 14,
STOP = 80,
- wrap = require('wordwrap')(TEXT_START, STOP);
+ wrap = require('wordwrap')(TEXT_START, STOP),
+ paraWrap = require('wordwrap')(1, STOP);
+
+function formatPara(text) {
+ return paraWrap(text);
+}
function formatOption(option, helpText) {
var formattedText = wrap(helpText);
@@ -20,5 +25,6 @@ function formatOption(option, helpText) {
}
module.exports = {
+ formatPara: formatPara,
formatOption: formatOption
};
Please sign in to comment.
Something went wrong with that request. Please try again.