Home Reference Source Test
import Helper from 'shinka-cli/src/Helper/Helper.js'
public class | source

Helper

Outputs examples for usage (--help) information.

Example:

new Helper().outputHelp(
     [{ command: "-v", description: "Outputs verbose error messages" }],
     "link"
);
// => Examples:
//        $ shinka link -v   Outputs verbose error messages

Test:

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

Used to output help, e.g.

Method Summary

Public Methods
public

Reducer helper for finding the example with the longest command.

public

help(examples: Example[], cmd: string): string[]

Builds usage examples.

public

outputHelp(examples: Example[], command: string)

Outputs usage examples.

Public Constructors

public constructor(logger: LogObject) source

Params:

NameTypeAttributeDescription
logger LogObject
  • optional
  • default: new Logger()

Object with #log method.

Test:

Public Members

public logger: LogObject source

Used to output help, e.g. Logger#log or console#log.

Public Methods

public getLongest(a: Example, b: Example): Example source

Reducer helper for finding the example with the longest command.

Params:

NameTypeAttributeDescription
a Example
b Example

Return:

Example

Example with longest command

Test:

public help(examples: Example[], cmd: string): string[] source

Builds usage examples.

Params:

NameTypeAttributeDescription
examples Example[]
  • optional
  • default: []
cmd string
  • optional
  • default: ""

Command name prepended to each example

Return:

string[]

Example:

new Helper().help(
     [{ command: "-v", description: "Outputs verbose error messages" }],
     "link"
);
// => ["\n  Examples: \n", "$ shinka link -v   Outputs verbose error messages"]

Test:

public outputHelp(examples: Example[], command: string) source

Outputs usage examples.

Params:

NameTypeAttributeDescription
examples Example[]
  • optional
  • default: []
command string
  • optional
  • default: ""
  • nullable: true

Command name prepended to each example

Example:

new Helper().outputHelp(
     [{ command: "-v", description: "Outputs verbose error messages" }],
     "link"
);
// => Examples:
//        $ shinka link -v   Outputs verbose error messages

Test: