Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CLI

Interface defining a command-line interface (in other words a command such as 'run', 'ls'...). This interface is polyglot to ease reuse such as in Vert.x Shell.

A command line interface has a name, and defines a set of options and arguments. Options are key-value pair such as -foo=bar or -flag. The supported formats depend on the used parser. Arguments are unlike options raw values. Options are defined using Option, while argument are defined using Argument.

Command line interfaces also define a summary and a description. These attributes are used in the usage generation . To disable the help generation, set the hidden attribute to true.

Command Line Interface object does not contains "value", it's a model. It must be evaluated by a parser that returns a CommandLine object containing the argument and option values.

Hierarchy

  • CLI

Index

Methods

addArgument

  • Adds an argument.

    Parameters

    Returns CLI

addArguments

  • Adds a set of arguments. Unlike {@link CLI#setArguments}, this method does not remove the existing arguments. The given list is appended to the existing list.

    Parameters

    Returns CLI

addOption

  • Adds an option.

    Parameters

    Returns CLI

addOptions

  • Adds a set of options. Unlike {@link CLI#setOptions}}, this method does not remove the existing options. The given list is appended to the existing list.

    Parameters

    Returns CLI

getArgument

  • getArgument(name: string): Argument | null
  • getArgument(index: number): Argument | null
  • Gets an Argument based on its name (argument name).

    Parameters

    • name: string

    Returns Argument | null

  • Gets an Argument based on its index.

    Parameters

    • index: number

    Returns Argument | null

getArguments

  • Gets the list of defined arguments.

    Returns Argument

getDescription

  • getDescription(): string | null
  • Returns string | null

getName

  • getName(): string
  • Returns string

getOption

  • getOption(name: string): Option | null
  • Gets an Option based on its name (short name, long name or argument name).

    Parameters

    • name: string

    Returns Option | null

getOptions

  • Gets the list of options.

    Returns Option

getPriority

  • getPriority(): number
  • Returns number

getSummary

  • getSummary(): string | null
  • Returns string | null

isHidden

  • isHidden(): boolean
  • Checks whether or not the current CLI instance is hidden.

    Returns boolean

parse

  • Parses the user command line interface and create a new CommandLine containing extracting values.

    Parameters

    • arguments: string

    Returns CommandLine

  • Parses the user command line interface and create a new CommandLine containing extracting values.

    Parameters

    • arguments: string
    • validate: boolean

    Returns CommandLine

removeArgument

  • removeArgument(index: number): CLI
  • Removes an argument identified by its index. This method does nothing if the argument cannot be found.

    Parameters

    • index: number

    Returns CLI

removeOption

  • removeOption(name: string): CLI
  • Removes an option identified by its name. This method does nothing if the option cannot be found.

    Parameters

    • name: string

    Returns CLI

setArguments

  • Sets the list of arguments.

    Parameters

    Returns CLI

setDescription

  • setDescription(desc: string): CLI
  • Parameters

    • desc: string

    Returns CLI

setHidden

  • setHidden(hidden: boolean): CLI
  • Sets whether or not the current instance of CLI must be hidden. Hidden CLI are not listed when displaying usages / help messages. In other words, hidden commands are for power user.

    Parameters

    • hidden: boolean

    Returns CLI

setName

  • setName(name: string): CLI
  • Sets the name of the CLI.

    Parameters

    • name: string

    Returns CLI

setOptions

  • Sets the list of arguments.

    Parameters

    Returns CLI

setPriority

  • setPriority(priority: number): CLI
  • Sets the priority of the CLI.

    Parameters

    • priority: number

    Returns CLI

setSummary

  • setSummary(summary: string): CLI
  • Sets the summary of the CLI.

    Parameters

    • summary: string

    Returns CLI

Static create

  • create(name: string): CLI
  • Creates an instance of CLI using the default implementation.

    Parameters

    • name: string

    Returns CLI

Generated using TypeDoc