Interface Parser

The command-line parser.

Index

Call signatures

Interfaces

Methods

Call signatures

(): NomnomInternal.Parser

Returns the parser.

Returns

NomnomInternal.Parser

Interfaces

Command: Command

A command-line command specification.

public name: string

The name of the command.

public callback(func: (options: any) => void): Command

Sets a callback for the command.

Parameters

  • func: (options: any) => void

    The callback function.

Returns

Command

The command.

public help(help: string): Command

Sets the help string for the command.

Parameters

  • help: string

    The help string.

Returns

Command

The command.

public option(name: string, spec: Option): Command

Sets an option of the command.

Parameters

  • name: string

    The name of the option.

  • spec: Option

    The specifiction of the option.

Returns

Command

The command.

public options(specs: { [index: string]: NomnomInternal.Parser.Option; }): Command

Sets the options of the command.

Parameters

  • specs: { [index: string]: NomnomInternal.Parser.Option; }

    The specifications of the options.

Returns

Command

The command.

public usage(usage: string): Command

Sets the usage string for the command.

Parameters

  • usage: string

    The usage string.

Returns

Command

The command.

Option: Option

A command-line option.

optional public abbr?: string

The abbreviated name of the option.

optional public callback?: (option: any) => string

A callback for the option.

optional public choices?: Array<string>

The choices for the option.

optional public default?: any

The default value of the option.

optional public flag?: boolean

Whether the option is a flag.

optional public full?: string

The full name of the option.

optional public help?: string

A help string for the option.

optional public hidden?: boolean

Whether the option is hidden.

optional public list?: boolean

Whether the option is a list.

optional public metavar?: string

A string to be used in the usage printout.

optional public position?: number

The position of the option if it's a positional argument.

optional public required?: boolean

Whether the option is required.

optional public string?: string

A shorthand for abbr, full, and metavar.

optional public type?: string

If you don't want the option JSON-parsed, specify type "string".

Methods

public command(name: string): Command

Creates a new command.

Parameters

  • name: string

    The name of the command.

Returns

Command

The new command.

public help(help: string): NomnomInternal.Parser

Sets the help string for the command-line.

Parameters

  • help: string

    The help string.

Returns

NomnomInternal.Parser

The command-line parser.

public nocolors(): NomnomInternal.Parser

Sets the command-line parser not to use colors.

Returns

NomnomInternal.Parser

The command-line parser.

public nocommand(): Command

Returns the commmand representing no command.

Returns

Command

The command representing no command.

public nom(argv?: Array<string>): any

Parses the command-line.

Parameters

  • argv?: Array<string> optional

    The command-line arguments.

Returns

any

The parsed command-line.

public option(name: string, spec: Option): NomnomInternal.Parser

Sets an option of the command-line.

Parameters

  • name: string

    The name of the option.

  • spec: Option

    The specifiction of the option.

Returns

NomnomInternal.Parser

The command-line parser.

public options(specs: { [index: string]: NomnomInternal.Parser.Option; }): NomnomInternal.Parser

Sets the options of the command-line.

Parameters

  • specs: { [index: string]: NomnomInternal.Parser.Option; }

    The specifications of the options.

Returns

NomnomInternal.Parser

The command-line parser.

public parse(argv?: Array<string>): any

Parses the command-line.

Parameters

  • argv?: Array<string> optional

    The command-line arguments.

Returns

any

The parsed command-line.

public printer(print: (message: string, code?: number) => void): NomnomInternal.Parser

Provides a printer to the command-line processor.

Parameters

  • print: (message: string, code?: number) => void

    The print function to use.

Returns

NomnomInternal.Parser

The command-line parser.

public script(script: string): NomnomInternal.Parser

Sets the name of the script.

Parameters

  • script: string

    The script name.

Returns

NomnomInternal.Parser

The command-line parser.

public usage(usage: string): NomnomInternal.Parser

Sets the usage string for the command-line.

Parameters

  • usage: string

    The usage string.

Returns

NomnomInternal.Parser

The command-line parser.