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
command-line-usage
Generates column-layout usage information for a command-line parser (e.g. command-line-args).
getUsage(definitions, options) ⇒ string
⏏
Kind: Exported function
Param | Type | Description |
---|---|---|
definitions | Array.<optionDefinition> |
an array of option definition objects. |
options | usage-options |
Options |
Example
Some example usage output:
my-app
Generates something useful
Usage
$ cat input.json | my-app [<options>]
$ my-app <files>
Main options
This group contains the most important options.
-a, --one <string> The first option
-b, --two <number> The second option
Miscellaneous
-c, --three <string> The third option
-d, --four <number> The fourth option
Project home: https://github.com/me/my-app
..and the code to create it:
var getUsage = require("command-line-usage");
var optionDefinitions = [
{ name: "help", alias: "h", type: Boolean, description: "Display this usage guide.", group: "main" },
{ name: "files", alias: "f", type: String, multiple: true, defaultOption: true, description: "The input files to process", group: "main" },
{ name: "timeout", alias: "t", type: Number, description: "Timeout value in ms", group: "main" },
{ name: "custom", type: Custom, description: "A custom class instance"}
];
var options = {
title: "%bold{a typical app}",
description: "Generates something %yellow bg-black{wild and crazy}",
forms: [
"$ cat input.json | my-app [<options>]",
"$ my-app <files>"
],
groups: {
main: {
title: "Main options",
description: "This group contains the most important options."
},
_none: "No group"
},
footer: "Project home: https://github.com/me/my-app",
hide: [ "files" ]
};
var usage = getUsage(optionDefinitions, options);
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
- UsageOptions ⏏
- instance
- .title :
string
|textObject
- .description :
string
|textObject
- .usage :
object
- .groups :
object
- .footer :
string
|textObject
- .hide :
string
|Array.<string>
- .title :
- inner
- instance
options.title : string
| textObject
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 textObject.
Kind: instance property of UsageOptions
Example
{
title: {
text: "my-app",
format: [ "bold", "underline" ]
}
}
options.description : string
| textObject
A description to go underneath the title. For example, some words about what the app is for.
Kind: instance property of UsageOptions
options.usage : object
An array of strings highlighting the main usage forms of the app.
Kind: instance property of UsageOptions
Properties
Name | Type | Default |
---|---|---|
title | string | textObject |
"Usage" |
format | string | Array.<string> |
Example
{
usage: {
title: "Synopsis",
forms: [
"$ my-app <options> <files>",
"$ my-app [-cvh]"
]
}
}
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.footer : string
| textObject
Displayed at the foot of the usage output.
Kind: instance property of UsageOptions
options.hide : string
| Array.<string>
If you want to hide certain options from the output, specify their names here.
Kind: instance property of UsageOptions
options~textObject
Contains text and formatting information.
Kind: inner typedef of UsageOptions
Properties
Name | Type | Description |
---|---|---|
text | string |
|
format | string | Array.<string> |
one or more ansi style names from this list. |
© 2015 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.