Overview

Namespaces

  • None
  • Peg
    • Cli
      • Commands
    • Config
    • Custom
      • Command
        • Action
          • Generate
          • Parse
      • CommandLine
      • Config
      • Localization
      • Utilities
    • Lib
      • Definitions
        • Element
      • Generator
      • Lexers
      • Plugins
      • Signals
        • Data
          • Definitions
          • Lexers
        • Type
  • PHP

Classes

  • Action
  • Command
  • Error
  • Option
  • OptionType
  • Parser
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo

Class Parser

Class in charge of parsing the command line options

Namespace: Peg\Custom\CommandLine
Located at src/CommandLine/Parser.php
Methods summary
public
# __construct( )

Initialize the parser.

Initialize the parser.

public Peg\Custom\CommandLine\Option[]
# GetOptions( )

Get array of options.

Get array of options.

Returns

Peg\Custom\CommandLine\Option[]
public Peg\Custom\CommandLine\Option|boolean
# GetOption( string $name )

Get an option by its long name.

Get an option by its long name.

Parameters

$name
string
$name

Returns

Peg\Custom\CommandLine\Option|boolean
public Peg\Custom\CommandLine\Command[]
# GetCommands( )

Get array of commands

Get array of commands

Returns

Peg\Custom\CommandLine\Command[]
public Peg\Custom\CommandLine\Command|boolean
# GetCommand( string $name )

Get a command object by its name.

Get a command object by its name.

Parameters

$name
string
$name

Returns

Peg\Custom\CommandLine\Command|boolean
public
# RegisterCommand( Peg\Custom\CommandLine\Command $command )

Adds a sub command to the parser.

Adds a sub command to the parser.

Parameters

$command
Peg\Custom\CommandLine\Command
$command

Throws

Exception
public
# RegisterOption( Peg\Custom\CommandLine\Option $option )

Adds an option to the parser.

Adds an option to the parser.

Parameters

$option
Peg\Custom\CommandLine\Option
$option

Throws

Exception
public
# Start( integer $argc, array $argv )

Begins the process of reading command line options and calling command actions as needed.

Begins the process of reading command line options and calling command actions as needed.

Parameters

$argc
integer
$argc
$argv
array
$argv
public
# PrintHelp( )

Generates and prints the help based on the registered commands and options.

Generates and prints the help based on the registered commands and options.

public
# PrintVersion( )

Generates and prints the help based on the registered commands and options.

Generates and prints the help based on the registered commands and options.

Properties summary
public string $application_name
#

Name of the main application using the command line parser, displayed when printing the help message.

Name of the main application using the command line parser, displayed when printing the help message.

public string $application_version
#

Version number of the main application using the command line parser, displayed when printing the help message.

Version number of the main application using the command line parser, displayed when printing the help message.

public string $application_description
#

Description of the main application using the command line parser, displayed when printing the help message.

Description of the main application using the command line parser, displayed when printing the help message.

PEG Api API documentation generated by ApiGen 2.8.0