JSPM

  • Created
  • Published
  • Downloads 2557567
  • Score
    100M100P100Q264174F
  • License MIT

Generates command-line usage information

Package Exports

  • command-line-usage
  • command-line-usage/lib/command-line-usage

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (command-line-usage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

view on npm npm module downloads per month Build Status Dependency Status

command-line-usage

Exports a single function to generate a usage guide using column-layout.

getUsage(definitions, options) ⇒ string

Kind: Exported function

Param Type Description
definitions Array.<optionDefinition> an array of option definition objects. In addition to the regular definition properties, command-line-usage will look for: - description - a string describing the option. - typeLabel - a string to replace the default type string (e.g. <string>). It's often more useful to set a more descriptive type label, like <ms>, <files>, <command> etc.
options usage-options see UsageOptions.

Example
Some example usage output:

usage

usage

UsageOptions ⏏

The class describes all valid options for the getUsage function. Inline formatting can be used within any text string supplied using valid ansi-escape-sequences formatting syntax.

Kind: Exported class

options.title : string

The title line at the top of the usage, typically the name of the app. By default it is underlined but this formatting can be overridden by passing a module:usage-options~textObject.

Kind: instance property of UsageOptions
Example

{
    title: "my-app"
}

Example

{
    title: {
       text: "my-app",
       format: [ "bold", "underline" ]
    }
}

options.description : string

A description to go underneath the title. For example, some words about what the app is for.

Kind: instance property of UsageOptions

options.synopsis : Array.<string>

An array of strings highlighting the main usage forms of the app.

Kind: instance property of UsageOptions

options.groups : object

Specify which groups to display in the output by supplying an object of key/value pairs, where the key is the name of the group to include and the value is a string or textObject. If the value is a string it is used as the group title. Alternatively supply an object containing a title and description string.

Kind: instance property of UsageOptions
Example

{
    main: {
        title: "Main options",
        description: "This group contains the most important options."
    },
    misc: "Miscellaneous"
}

options.examples : Array.<string> | Array.<object>

Examples

Kind: instance property of UsageOptions

options.footer : string

Displayed at the foot of the usage output.

Kind: instance property of UsageOptions
Example

{
    footer: "Project home: [underline]{https://github.com/me/my-app}"
}

options.hide : string | Array.<string>

If you want to hide certain options from the output, specify their names here. This is sometimes used to hide the defaultOption.

Kind: instance property of UsageOptions
Example

{
    hide: "files"
}

More examples

You can see output from the examples in the examples folder using the test harness. To install:

$ npm install -g command-line-usage

Usage:

$ cat example/typical-formatted.js | command-line-usage

© 2015 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.