Properties

$ident

$ident : string

Type

string

$description

$description : string

Type

string

$arguments

$arguments : array

Type

array

$climate

$climate : \League\CLImate\CLImate

Type

\League\CLImate\CLImate

$climateReader

$climateReader : \League\CLImate\Util\Reader\ReaderInterface

Type

\League\CLImate\Util\Reader\ReaderInterface

$quiet

$quiet : boolean

Type

boolean

$verbose

$verbose : boolean

Type

boolean

$interactive

$interactive : boolean

Type

boolean

$dryRun

$dryRun : boolean

Type

boolean

Methods

__construct()

__construct(array|\ArrayAccess  $data = null) 

Return a new CLI script.

Parameters

array|\ArrayAccess $data

The dependencies (app and logger).

setDependencies()

setDependencies(\Pimple\Container  $container) : void

Give an opportunity to children classes to inject dependencies from a Pimple Container.

Does nothing by default, reimplement in children classes.

The $container DI-container (from Pimple) should not be saved or passed around, only to be used to inject dependencies (typically via setters).

Parameters

\Pimple\Container $container

A dependencies container instance.

__invoke()

__invoke(\Psr\Http\Message\RequestInterface  $request, \Psr\Http\Message\ResponseInterface  $response) : \Psr\Http\Message\ResponseInterface

Parameters

\Psr\Http\Message\RequestInterface $request

A PSR-7 compatible Request instance.

\Psr\Http\Message\ResponseInterface $response

A PSR-7 compatible Response instance.

Returns

\Psr\Http\Message\ResponseInterface

defaultArguments()

defaultArguments() : array

Retrieve the script's supported arguments.

Returns

array

setIdent()

setIdent(string  $ident) : \Charcoal\App\Script\ScriptInterface

Parameters

string $ident

The script identifier string.

Throws

\InvalidArgumentException

If the ident argument is not a string.

Returns

\Charcoal\App\Script\ScriptInterface

Chainable

ident()

ident() : string

Returns

string

setDescription()

setDescription(string  $description) : \Charcoal\App\Script\ScriptInterface

Parameters

string $description

The script description.

Throws

\InvalidArgumentException

If the deescription parameter is not a string.

Returns

\Charcoal\App\Script\ScriptInterface

Chainable

description()

description() : string

Returns

string

quiet()

quiet() : boolean

Returns

boolean

setVerbose()

setVerbose(boolean  $verbose) : \Charcoal\App\Script\ScriptInterface

Parameters

boolean $verbose

The verbose flag.

Returns

\Charcoal\App\Script\ScriptInterface

Chainable

verbose()

verbose() : boolean

Returns

boolean

setInteractive()

setInteractive(boolean  $interactive) : \Charcoal\App\Script\ScriptInterface

Parameters

boolean $interactive

The interactive flag.

Returns

\Charcoal\App\Script\ScriptInterface

Chainable

interactive()

interactive() : boolean

Returns

boolean

setDryRun()

setDryRun(boolean  $simulate) : \Charcoal\App\Script\ScriptInterface

Parameters

boolean $simulate

The dry-run flag.

Returns

\Charcoal\App\Script\ScriptInterface

Chainable

dryRun()

dryRun() : boolean

Returns

boolean

setArguments()

setArguments(array  $arguments) : \Charcoal\App\Script\ScriptInterface

Parameters

array $arguments

The scripts argument array, as [key=>value].

Returns

\Charcoal\App\Script\ScriptInterface

Chainable

addArgument()

addArgument(string  $argumentIdent, array  $argument) : \Charcoal\App\Script\ScriptInterface

Parameters

string $argumentIdent

The argument identifier.

array $argument

The argument options.

Throws

\InvalidArgumentException

If the argument ident is not a string.

Returns

\Charcoal\App\Script\ScriptInterface

Chainable

arguments()

arguments() : array

Returns

array —

$arguments

argument()

argument(string  $argumentIdent) : array|null

Parameters

string $argumentIdent

The argument identifier to retrieve options from.

Returns

array|null —

The argument options, or null if it does not exist.

init()

init() : void

climate()

climate() : \League\CLImate\CLImate

Safe climate getter.

If the instance was not previously set, create it.

CLImate is "PHP's best friend for the terminal." "CLImate allows you to easily output colored text, special formats, and more."

Returns

\League\CLImate\CLImate

climateReader()

climateReader() : \League\CLImate\Util\Reader\ReaderInterface

Returns

\League\CLImate\Util\Reader\ReaderInterface

argOrInput()

argOrInput(string  $argName) : mixed

Retrieve an argument either from argument list (if set) or from user input.

Parameters

string $argName

An argument identifier.

Returns

mixed —

Returns the argument or prompt value.

input()

input(string  $name) : mixed

Request a value from the user for the given argument.

Parameters

string $name

An argument identifier.

Throws

\RuntimeException

If a radio or checkbox prompt has no options.

Returns

mixed —

Returns the prompt value.

setClimate()

setClimate(\League\CLImate\CLImate  $climate) : void

Parameters

\League\CLImate\CLImate $climate

A climate instance.

setClimateReader()

setClimateReader(\League\CLImate\Util\Reader\ReaderInterface  $climateReader) : void

Parameters

\League\CLImate\Util\Reader\ReaderInterface $climateReader

A climate reader.