Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

command-line-usage

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

command-line-usage - npm Package Compare versions

Comparing version 6.0.0-0 to 6.0.0-1

2

index.js

@@ -25,2 +25,4 @@ /**

return '\n' + output.join('\n')
} else {
return ''
}

@@ -27,0 +29,0 @@ }

2

lib/content.js

@@ -16,3 +16,3 @@ const Table = require('table-layout')

/* string content */
if (typeof content === 'string') {
if (t.isString(content)) {
const table = new Table({ column: chalkFormat(content) }, {

@@ -19,0 +19,0 @@ padding: defaultPadding,

@@ -59,4 +59,4 @@ const Section = require('./section')

function getOptionNames (definition, reverseNameOrder) {
let type = definition.type ? definition.type.name.toLowerCase() : ''
const multiple = definition.multiple ? '[]' : ''
let type = definition.type ? definition.type.name.toLowerCase() : 'string'
const multiple = (definition.multiple || definition.lazyMultiple) ? '[]' : ''
if (type) {

@@ -63,0 +63,0 @@ type = type === 'boolean' ? '' : `{underline ${type}${multiple}}`

{
"name": "command-line-usage",
"author": "Lloyd Brookes <75pound@gmail.com>",
"version": "6.0.0-0",
"version": "6.0.0-1",
"description": "Generates command-line usage information",

@@ -22,3 +22,3 @@ "repository": "https://github.com/75lb/command-line-usage.git",

"scripts": {
"docs": "jsdoc2md -t jsdoc2md/README.hbs --no-gfm index.js > README.md; echo",
"docs": "jsdoc2md --no-gfm index.js > doc/api.md; echo",
"test": "test-runner test/*.js",

@@ -31,3 +31,3 @@ "cover": "nyc npm test && nyc report --reporter=text-lcov | coveralls"

"table-layout": "^1.0.0",
"typical": "^5.0.0"
"typical": "^5.1.0"
},

@@ -34,0 +34,0 @@ "devDependencies": {

@@ -7,2 +7,4 @@ [![view on npm](http://img.shields.io/npm/v/command-line-usage.svg)](https://www.npmjs.org/package/command-line-usage)

***Upgraders, please check the [release notes](https://github.com/75lb/command-line-usage/releases).***
# command-line-usage

@@ -105,177 +107,4 @@

## API Reference
* [command-line-usage](#module_command-line-usage)
* [commandLineUsage(sections)](#exp_module_command-line-usage--commandLineUsage) ⇒ <code>string</code> ⏏
* [~content](#module_command-line-usage--commandLineUsage..content)
* [~optionList](#module_command-line-usage--commandLineUsage..optionList)
<a name="exp_module_command-line-usage--commandLineUsage"></a>
### commandLineUsage(sections) ⇒ <code>string</code> ⏏
Generates a usage guide suitable for a command-line app.
**Kind**: Exported function
<table>
<thead>
<tr>
<th>Param</th><th>Type</th><th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>sections</td><td><code>Section</code> | <code>Array.&lt;Section&gt;</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>
</tr> </tbody>
</table>
<a name="module_command-line-usage--commandLineUsage..content"></a>
#### commandLineUsage~content
A Content section comprises a header and one or more lines of content.
**Kind**: inner typedef of [<code>commandLineUsage</code>](#exp_module_command-line-usage--commandLineUsage)
**Properties**
<table>
<thead>
<tr>
<th>Name</th><th>Type</th><th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>header</td><td><code>string</code></td><td><p>The section header, always bold and underlined.</p>
</td>
</tr><tr>
<td>content</td><td><code>string</code> | <code>Array.&lt;string&gt;</code> | <code>Array.&lt;object&gt;</code></td><td><p>Overloaded property, accepting data in one of four formats:</p>
<ol>
<li>A single string (one line of text)</li>
<li>An array of strings (multiple lines of text)</li>
<li>An array of objects (recordset-style data). In this case, the data will be rendered in table format. The property names of each object are not important, so long as they are consistent throughout the array.</li>
<li>An object with two properties - <code>data</code> and <code>options</code>. In this case, the data and options will be passed directly to the underlying <a href="https://github.com/75lb/table-layout">table layout</a> module for rendering.</li>
</ol>
</td>
</tr><tr>
<td>raw</td><td><code>boolean</code></td><td><p>Set to true to avoid indentation and wrapping. Useful for banners.</p>
</td>
</tr> </tbody>
</table>
**Example**
Simple string of content. For ansi formatting, use [chalk template literal syntax](https://github.com/chalk/chalk#tagged-template-literal).
```js
{
header: 'A typical app',
content: 'Generates something {rgb(255,200,0).italic very {underline.bgRed important}}.'
}
```
An array of strings is interpreted as lines, to be joined by the system newline character.
```js
{
header: 'A typical app',
content: [
'First line.',
'Second line.'
]
}
```
An array of recordset-style objects are rendered in table layout.
```js
{
header: 'A typical app',
content: [
{ colA: 'First row, first column.', colB: 'First row, second column.'},
{ colA: 'Second row, first column.', colB: 'Second row, second column.'}
]
}
```
An object with `data` and `options` properties will be passed directly to the underlying [table layout](https://github.com/75lb/table-layout) module for rendering.
```js
{
header: 'A typical app',
content: {
data: [
{ colA: 'First row, first column.', colB: 'First row, second column.'},
{ colA: 'Second row, first column.', colB: 'Second row, second column.'}
],
options: {
maxWidth: 60
}
}
}
```
<a name="module_command-line-usage--commandLineUsage..optionList"></a>
#### commandLineUsage~optionList
An OptionList section adds a table displaying the supplied option definitions.
**Kind**: inner typedef of [<code>commandLineUsage</code>](#exp_module_command-line-usage--commandLineUsage)
**Properties**
<table>
<thead>
<tr>
<th>Name</th><th>Type</th><th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>[header]</td><td><code>string</code></td><td><p>The section header, always bold and underlined.</p>
</td>
</tr><tr>
<td>optionList</td><td><code>Array.&lt;OptionDefinition&gt;</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>
<li><code>description</code> - a string describing the option.</li>
<li><code>typeLabel</code> - a string to replace the default type string (e.g. <code>&lt;string&gt;</code>). It&#39;s often more useful to set a more descriptive type label, like <code>&lt;ms&gt;</code>, <code>&lt;files&gt;</code>, <code>&lt;command&gt;</code> etc.</li>
</ul>
</td>
</tr><tr>
<td>[group]</td><td><code>string</code> | <code>Array.&lt;string&gt;</code></td><td><p>If specified, only options from this particular group will be printed. <a href="https://github.com/75lb/command-line-usage/blob/master/example/groups.js">Example</a>.</p>
</td>
</tr><tr>
<td>[hide]</td><td><code>string</code> | <code>Array.&lt;string&gt;</code></td><td><p>The names of one of more option definitions to hide from the option list. <a href="https://github.com/75lb/command-line-usage/blob/master/example/hide.js">Example</a>.</p>
</td>
</tr><tr>
<td>[reverseNameOrder]</td><td><code>boolean</code></td><td><p>If true, the option alias will be displayed after the name, i.e. <code>--verbose, -v</code> instead of <code>-v, --verbose</code>).</p>
</td>
</tr><tr>
<td>[tableOptions]</td><td><code>object</code></td><td><p>An options object suitable for passing into <a href="https://github.com/75lb/table-layout#table-">table-layout</a>. See <a href="https://github.com/75lb/command-line-usage/blob/master/example/option-list-options.js">here for an example</a>.</p>
</td>
</tr> </tbody>
</table>
**Example**
```js
{
header: 'Options',
optionList: [
{
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: 'timeout',
description: 'Timeout value in ms.',
alias: 't',
typeLabel: '{underline ms}'
}
]
}
```
* * *
&copy; 2015-19 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/75lb/jsdoc-to-markdown).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc