Skip to content

Latest commit

 

History

History
146 lines (92 loc) · 4.22 KB

api.md

File metadata and controls

146 lines (92 loc) · 4.22 KB

Table of Contents

ArgsAndFlags

Parse and validate args and flags for cli tools

Parameters

  • options
  • args arguments
  • flags flags
  • indent how many spaces to indent help text

parse

Parse and validate args and flags for cli tools

Parameters

  • argsInput Array<object> actual args supplied at command line

Returns object

helpObject

Get help information for all args and flags as an object

Parameters

  • options object?
    • options.indent string? amount to indent lines

Returns object

help

Get help text for all args

Parameters

  • options object?
    • options.argsHeaderText string? header text above list of arguments. default is Arguments
    • options.flagsHeaderText string? header text above list of flags. default is Flags
    • options.leftColumnWidth number? width of left section in columns. default is the length of the longest arg or flag name
    • options.rightColumnWidth number? width of right section in columns. default is the full width of the terminal minus the leftColumnWidth
    • options.gutter number? width of gutter in columns. default is 4

Returns string

formatDescription

Format description

Parameters

  • text string description text
  • leftColumnWidth number width of left section in columns
  • rightColumnWidth number width of right section in columns
  • gutter number width of gutter in columns

Returns string

argsHelp

Get help text for all args

Parameters

  • options object
    • options.lines array lines of text in an array
    • options.longestLine integer integer for the longest line in the array of lines (of both args and flags)
    • options.headerText string? header text above list of arguments. default is Arguments:
    • options.leftColumnWidth number? width of left section in columns. default is the length of the longest arg or flag name
    • options.rightColumnWidth number? width of right section in columns. default is the full width of the terminal minus the leftColumnWidth
    • options.gutter number? width of gutter in columns. default is 4

Returns string

flagsHelp

Get help text for all flags

Parameters

  • options object
    • options.lines array lines of text in an array
    • options.longestLine integer integer for the longest line in the array of lines (of both args and flags)
    • options.headerText string? header text above list of flags. default is Flags:
    • options.leftColumnWidth number? width of left section in columns. default is the length of the longest arg or flag name
    • options.rightColumnWidth number? width of right section in columns. default is the full width of the terminal minus the leftColumnWidth
    • options.gutter number? width of gutter in columns. default is 4

Returns string