Overview

Namespaces

  • LucidFrame
    • Console
    • Core
    • File
  • None

Classes

  • Command
  • Console
  • ConsoleTable

Interfaces

  • CommandInterface
  • Overview
  • Namespace
  • Class

Class Command

This class manages the process of a Command

Namespace: LucidFrame\Console
Located at classes/console/Command.php
Methods summary
public
# __construct( string $name )

Constructor

Constructor

Parameters

$name
The command name
public object
# setName( string $name )

Setter for $name

Setter for $name

Parameters

$name
The command name

Returns

object
LucidFrame\Console\Command
public string
# getName( )

Getter for $name

Getter for $name

Returns

string
public object
# setDescription( string $description = null )

Setter for $description

Setter for $description

Parameters

$description
The description for the command

Returns

object
LucidFrame\Console\Command
public string
# getDescription( )

Setter for $description

Setter for $description

Returns

string
public object
# setHelp( string $help = null )

Setter for $help

Setter for $help

Parameters

$help
The help tip for the command

Returns

object
LucidFrame\Console\Command`
public string
# getHelp( )

Setter for $help

Setter for $help

Returns

string
public object
# addOption( string $name, string $shortcut = null, string $description = '', mixed $default = null, integer $type = LC_CONSOLE_OPTION_OPTIONAL )

Add an option for the command

Add an option for the command

Parameters

$name
The option name without the prefix --, i.e,. help for --help
$shortcut
The short option name without the prefix -, i.e, h for -h
$description
A short description for the option
$default
The default value for the option
$type
A constant: LC_CONSOLE_OPTION_REQUIRED, LC_CONSOLE_OPTION_OPTIONAL, LC_CONSOLE_OPTION_NOVALUE

Returns

object
LucidFrame\Console\Command
public object
# addArgument( string $name, string $description = '', mixed $default = null )

Add an argument for the command

Add an argument for the command

Parameters

$name
The argument name
$description
A short description for the argument
$default
The default value for the option

Returns

object
LucidFrame\Console\Command
public
# getArguments( )

Getter for $parsedArguments

Getter for $parsedArguments

public
# getOptions( )

Getter for $parsedOptions

Getter for $parsedOptions

public object
# setDefinition( closure|string $function )

Setter for $definition

Setter for $definition

Parameters

$function
Anonymous function or class name that performs the job of the command

Returns

object
LucidFrame\Console\Command`
public object
# register( )

Register a command

Register a command

Returns

object
LucidFrame\Console\Command`
public mixed
# getOption( string $name )

Get an option from the command

Get an option from the command

Parameters

$name
The option name without the prefix --, i.e,. help for --help

Returns

mixed
public mixed
# getArgument( string $name )

Get an argument from the command

Get an argument from the command

Parameters

$name
The argument name

Returns

mixed
public
# getParsedOptions( )

Getter for $parsedOptions

Getter for $parsedOptions

public
# getParsedArguments( )

Getter for $parsedArguments

Getter for $parsedArguments

public
# resetToDefaults( )

Reset default values to arguments and options

Reset default values to arguments and options

public mixed
# run( array $argv = array() )

Run the command

Run the command

Parameters

$argv
Array of arguments passed to script

Returns

mixed
public
# showHelp( )

Display the help message

Display the help message

public array
# parseArguments( array $argv = array() )

Parse the arguments for the command

Parse the arguments for the command

Parameters

$argv
Array of arguments passed to script

Returns

array
public boolean
# confirm( string $message = 'Are you sure? Type "yes" or "y" to continue:', string|array $input = array('yes', 'y') )

Console confirmation prompt

Console confirmation prompt

Parameters

$message
The confirmation message
$input
The input to be allowed or to be checked against

Returns

boolean
TRUE if it is passed; otherwise FALSE
Properties summary
protected string $name

The command name

The command name

#
protected string $description

The description for the command

The description for the command

#
protected string $help

The help tip for the command

The help tip for the command

#
protected array $options

The options for the command such as --help etc.

The options for the command such as --help etc.

# array()
protected array $shortcuts

The short options of the long options defined for the command such as -h for --help, etc.

The short options of the long options defined for the command such as -h for --help, etc.

# array()
protected array $arguments

The arguments for the command

The arguments for the command

# array()
protected array $argumentNames

Array of the argument names

Array of the argument names

# array()
protected closure|string $definition

Anonymous function or class name that performs the job of the command

Anonymous function or class name that performs the job of the command

#
PHPLucidFrame 3.2 API documentation generated by ApiGen