@types/command-line-usage

  • Version 5.0.1
  • Published
  • 7 kB
  • No dependencies
  • MIT license

Install

npm i @types/command-line-usage
yarn add @types/command-line-usage
pnpm add @types/command-line-usage

Overview

TypeScript definitions for command-line-usage

Index

Functions

function commandLineUsage

commandLineUsage: (
sections: commandLineUsage.Section | commandLineUsage.Section[]
) => string;
  • Generates a usage guide suitable for a command-line app.

    Parameter sections

    One or more Section objects module:command-line-usage

Interfaces

interface Content

interface Content {}
  • A Content section comprises a header and one or more lines of content.

property content

content?: string | string[] | any[] | { data: any; options: any };
  • Overloaded property, accepting data in one of four formats. 1. A single string (one line of text). 2. An array of strings (multiple lines of text). 3. 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. 4. An object with two properties - data and options. In this case, the data and options will be passed directly to the underlying table layout module for rendering.

property header

header?: string;
  • The section header, always bold and underlined.

property raw

raw?: boolean;
  • Set to true to avoid indentation and wrapping. Useful for banners.

interface OptionDefinition

interface OptionDefinition {}
  • Describes a command-line option. Additionally, if generating a usage guide with command-line-usage you could optionally add description and typeLabel properties to each definition.

property alias

alias?: string;
  • getopt-style short option names. Can be any single character (unicode included) except a digit or hyphen.

property defaultOption

defaultOption?: boolean;
  • Any values unaccounted for by an option definition will be set on the defaultOption. This flag is typically set on the most commonly-used option to make for more concise usage.

property defaultValue

defaultValue?: any;
  • An initial value for the option.

property description

description?: string;
  • A string describing the option.

property group

group?: string | string[];
  • When your app has a large amount of options it makes sense to organise them in groups.

    There are two automatic groups: _all (contains all options) and _none (contains options without a group specified in their definition).

property lazyMultiple

lazyMultiple?: boolean;
  • Identical to multiple but with greedy parsing disabled.

property multiple

multiple?: boolean;
  • Set this flag if the option takes a list of values. You will receive an array of values, each passed through the type function (if specified).

property name

name: string;

    property type

    type?: any;
    • The type value is a setter function (you receive the output from this), enabling you to be specific about the type and value received.

      The most common values used are String (the default), Number and Boolean but you can use a custom function.

    property typeLabel

    typeLabel?: string;
    • A string to replace the default type string (e.g. ). It's often more useful to set a more descriptive type label, like , , , etc..

    interface OptionList

    interface OptionList {}
    • A OptionList section adds a table displaying details of the available options.

    property group

    group?: string | string[];
    • If specified, only options from this particular group will be printed.

    property header

    header?: string;

      property hide

      hide?: string | string[];
      • The names of one of more option definitions to hide from the option list.

      property optionList

      optionList?: OptionDefinition[];
      • An array of option definition objects.

      property reverseNameOrder

      reverseNameOrder?: boolean;
      • If true, the option alias will be displayed after the name, i.e. --verbose, -v instead of -v, --verbose).

      property tableOptions

      tableOptions?: any;
      • An options object suitable for passing into table-layout.

      Type Aliases

      type Section

      type Section = Content | OptionList;
      • Section object.

      Package Files (1)

      Dependencies (0)

      No dependencies.

      Dev Dependencies (0)

      No dev dependencies.

      Peer Dependencies (0)

      No peer dependencies.

      Badge

      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/command-line-usage.

      • Markdown
        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/command-line-usage)
      • HTML
        <a href="https://www.jsdocs.io/package/@types/command-line-usage"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>