command-line-usage
Advanced tools
Comparing version
27
index.js
@@ -1,10 +0,8 @@ | ||
'use strict' | ||
/** | ||
* @module command-line-usage | ||
*/ | ||
module.exports = commandLineUsage | ||
/** | ||
* Generates a usage guide suitable for a command-line app. | ||
* @param {Section|Section[]} - One of more section objects ({@link module:command-line-usage~content} or {@link module:command-line-usage~optionList}). | ||
* @param {Section|Section[]} - One or more section objects ({@link module:command-line-usage~content} or {@link module:command-line-usage~optionList}). | ||
* @returns {string} | ||
@@ -91,6 +89,6 @@ * @alias module:command-line-usage | ||
/** | ||
* A OptionList section adds a table displaying details of the available options. | ||
* An OptionList section adds a table displaying the supplied option definitions. | ||
* @typedef module:command-line-usage~optionList | ||
* @property {string} [header] - The section header, always bold and underlined. | ||
* @property optionList {OptionDefinition[]} - an array of [option definition](https://github.com/75lb/command-line-args/blob/master/doc/option-definition.md) objects. In addition to the regular definition properties, command-line-usage will look for: | ||
* @property optionList {OptionDefinition[]} - An array of [option definition](https://github.com/75lb/command-line-args/blob/master/doc/option-definition.md) objects. In addition to the regular definition properties, command-line-usage will look for: | ||
* | ||
@@ -109,11 +107,18 @@ * - `description` - a string describing the option. | ||
* { | ||
* name: 'help', alias: 'h', description: 'Display this usage guide.' | ||
* name: 'help', | ||
* alias: 'h', | ||
* description: 'Display this usage guide.' | ||
* }, | ||
* { | ||
* name: 'src', description: 'The input files to process', | ||
* multiple: true, defaultOption: true, typeLabel: '{underline file} ...' | ||
* name: 'src', | ||
* description: 'The input files to process', | ||
* multiple: true, | ||
* defaultOption: true, | ||
* typeLabel: '{underline file} ...' | ||
* }, | ||
* { | ||
* name: 'timeout', description: 'Timeout value in ms. This description is needlessly long unless you count testing of the description column maxWidth useful.', | ||
* alias: 't', typeLabel: '{underline ms}' | ||
* name: 'timeout', | ||
* description: 'Timeout value in ms.', | ||
* alias: 't', | ||
* typeLabel: '{underline ms}' | ||
* } | ||
@@ -123,1 +128,3 @@ * ] | ||
*/ | ||
module.exports = commandLineUsage |
@@ -1,2 +0,1 @@ | ||
'use strict' | ||
const Section = require('./section') | ||
@@ -3,0 +2,0 @@ |
@@ -1,2 +0,1 @@ | ||
'use strict' | ||
const Table = require('table-layout') | ||
@@ -17,3 +16,3 @@ const chalkFormat = require('./chalk-format') | ||
/* string content */ | ||
if (t.isString(content)) { | ||
if (typeof content === 'string') { | ||
const table = new Table({ column: chalkFormat(content) }, { | ||
@@ -20,0 +19,0 @@ padding: defaultPadding, |
@@ -1,2 +0,1 @@ | ||
'use strict' | ||
const Section = require('./section') | ||
@@ -3,0 +2,0 @@ const Table = require('table-layout') |
@@ -1,3 +0,1 @@ | ||
'use strict' | ||
class Section { | ||
@@ -4,0 +2,0 @@ constructor () { |
{ | ||
"name": "command-line-usage", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "5.0.5", | ||
"version": "6.0.0-0", | ||
"description": "Generates command-line usage information", | ||
@@ -9,3 +9,3 @@ "repository": "https://github.com/75lb/command-line-usage.git", | ||
"files": [ | ||
"lib", | ||
"lib/*.js", | ||
"index.js" | ||
@@ -20,18 +20,21 @@ ], | ||
"engines": { | ||
"node": ">=4.0.0" | ||
"node": ">=8.0.0" | ||
}, | ||
"scripts": { | ||
"docs": "jsdoc2md -t jsdoc2md/README.hbs --no-gfm index.js > README.md; echo", | ||
"test": "test-runner test/*.js" | ||
"test": "test-runner test/*.js", | ||
"cover": "nyc npm test && nyc report --reporter=text-lcov | coveralls" | ||
}, | ||
"dependencies": { | ||
"array-back": "^2.0.0", | ||
"chalk": "^2.4.1", | ||
"table-layout": "^0.4.3", | ||
"typical": "^2.6.1" | ||
"array-back": "^3.1.0", | ||
"chalk": "^2.4.2", | ||
"table-layout": "^1.0.0", | ||
"typical": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"jsdoc-to-markdown": "^4.0.1", | ||
"test-runner": "^0.5.0" | ||
"coveralls": "^3.0.4", | ||
"jsdoc-to-markdown": "^5.0.0", | ||
"nyc": "^14.1.1", | ||
"test-runner": "^0.6.0" | ||
} | ||
} |
[](https://www.npmjs.org/package/command-line-usage) | ||
[](https://www.npmjs.org/package/command-line-usage) | ||
[](https://travis-ci.org/75lb/command-line-usage) | ||
[](https://david-dm.org/75lb/command-line-usage) | ||
[](https://david-dm.org/75lb/command-line-usage) | ||
[](https://github.com/feross/standard) | ||
# command-line-usage | ||
A simple, data-driven module for creating a usage guide. | ||
## Synopsis | ||
A usage guide is created by first defining an arbitrary number of sections, e.g. a description section, synopsis, option list, examples, footer etc. Each section has an optional header, some content and must be of type <code><a href="#commandlineusagecontent">content</a></code> or <code><a href="#commandlineusageoptionlist">optionList</a></code>. This section data is passed to <code><a href="#commandlineusagesections--string-">commandLineUsage()</a></code> which returns a usage guide. | ||
@@ -124,3 +126,3 @@ | ||
<tr> | ||
<td>sections</td><td><code>Section</code> | <code>Array.<Section></code></td><td><p>One of more section objects (<a href="#module_command-line-usage--commandLineUsage..content">content</a> or <a href="#module_command-line-usage--commandLineUsage..optionList">optionList</a>).</p> | ||
<td>sections</td><td><code>Section</code> | <code>Array.<Section></code></td><td><p>One or more section objects (<a href="#module_command-line-usage--commandLineUsage..content">content</a> or <a href="#module_command-line-usage--commandLineUsage..optionList">optionList</a>).</p> | ||
</td> | ||
@@ -212,3 +214,3 @@ </tr> </tbody> | ||
#### commandLineUsage~optionList | ||
A OptionList section adds a table displaying details of the available options. | ||
An OptionList section adds a table displaying the supplied option definitions. | ||
@@ -229,3 +231,3 @@ **Kind**: inner typedef of [<code>commandLineUsage</code>](#exp_module_command-line-usage--commandLineUsage) | ||
</tr><tr> | ||
<td>optionList</td><td><code>Array.<OptionDefinition></code></td><td><p>an array of <a href="https://github.com/75lb/command-line-args/blob/master/doc/option-definition.md">option definition</a> objects. In addition to the regular definition properties, command-line-usage will look for:</p> | ||
<td>optionList</td><td><code>Array.<OptionDefinition></code></td><td><p>An array of <a href="https://github.com/75lb/command-line-args/blob/master/doc/option-definition.md">option definition</a> objects. In addition to the regular definition properties, command-line-usage will look for:</p> | ||
<ul> | ||
@@ -257,11 +259,18 @@ <li><code>description</code> - a string describing the option.</li> | ||
{ | ||
name: 'help', alias: 'h', description: 'Display this usage guide.' | ||
name: 'help', | ||
alias: 'h', | ||
description: 'Display this usage guide.' | ||
}, | ||
{ | ||
name: 'src', description: 'The input files to process', | ||
multiple: true, defaultOption: true, typeLabel: '{underline file} ...' | ||
name: 'src', | ||
description: 'The input files to process', | ||
multiple: true, | ||
defaultOption: true, | ||
typeLabel: '{underline file} ...' | ||
}, | ||
{ | ||
name: 'timeout', description: 'Timeout value in ms. This description is needlessly long unless you count testing of the description column maxWidth useful.', | ||
alias: 't', typeLabel: '{underline ms}' | ||
name: 'timeout', | ||
description: 'Timeout value in ms.', | ||
alias: 't', | ||
typeLabel: '{underline ms}' | ||
} | ||
@@ -274,2 +283,2 @@ ] | ||
© 2015-18 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/75lb/jsdoc-to-markdown). | ||
© 2015-19 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/75lb/jsdoc-to-markdown). |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
329
0.61%280
3.32%26134
-0.06%4
100%2
100%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated