Overview

Namespaces

  • Charcoal
    • App
      • Action
      • Config
      • Handler
      • Middleware
      • Module
      • Route
      • Script
      • ServiceProvider
      • Template

Classes

  • AbstractScript

Interfaces

  • CronScriptInterface
  • ScriptInterface

Traits

  • ArgScriptTrait
  • CronScriptTrait
  • PathScriptTrait
  • Overview
  • Namespace
  • Class

Class AbstractScript

Abstract CLI Script

Charcoal\Config\AbstractEntity
Extended by Charcoal\App\Script\AbstractScript implements Psr\Log\LoggerAwareInterface, Charcoal\App\Script\ScriptInterface uses Psr\Log\LoggerAwareTrait (not available)
Abstract
Namespace: Charcoal\App\Script
Located at Charcoal/App/Script/AbstractScript.php
Methods summary
public
# __construct( array|ArrayAccess $data = null )

Return a new CLI script.

Return a new CLI script.

Parameters

$data
The dependencies (app and logger).
public
# setDependencies( Pimple\Container $container )

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

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

$container
A dependencies container instance.

Implementation of

Charcoal\App\Script\ScriptInterface::setDependencies()
protected
# init( )
final public Psr\Http\Message\ResponseInterface
# __invoke( Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response )

Parameters

$request
A PSR-7 compatible Request instance.
$response
A PSR-7 compatible Response instance.

Returns

Psr\Http\Message\ResponseInterface
protected League\CLImate\CLImate
# climate( )

Safe climate getter. If the instance was not previously set, create it.

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
protected League\CLImate\Util\Reader\ReaderInterface
# climateReader( )

Returns

League\CLImate\Util\Reader\ReaderInterface
public array
# defaultArguments( )

Retrieve the script's supported arguments.

Retrieve the script's supported arguments.

Returns

array
public Charcoal\App\Script\ScriptInterface
# setIdent( string $ident )

Parameters

$ident
The script identifier string.

Returns

Charcoal\App\Script\ScriptInterface
Chainable

Throws

InvalidArgumentException
If the ident argument is not a string.

Implementation of

Charcoal\App\Script\ScriptInterface::setIdent()
public string
# ident( )

Returns

string

Implementation of

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

Parameters

$description
The script description.

Returns

Charcoal\App\Script\ScriptInterface
Chainable

Throws

InvalidArgumentException
If the deescription parameter is not a string.

Implementation of

Charcoal\App\Script\ScriptInterface::setDescription()
public string
# description( )

Returns

string

Implementation of

Charcoal\App\Script\ScriptInterface::description()
public Charcoal\App\Script\ScriptInterface
# setQuiet( boolean $quiet )

Parameters

$quiet
The quiet flag.

Returns

Charcoal\App\Script\ScriptInterface
Chainable
public boolean
# quiet( )

Returns

boolean
public Charcoal\App\Script\ScriptInterface
# setVerbose( boolean $verbose )

Parameters

$verbose
The verbose flag.

Returns

Charcoal\App\Script\ScriptInterface
Chainable
public boolean
# verbose( )

Returns

boolean
public Charcoal\App\Script\ScriptInterface
# setInteractive( boolean $interactive )

Parameters

$interactive
The interactive flag.

Returns

Charcoal\App\Script\ScriptInterface
Chainable
public boolean
# interactive( )

Returns

boolean
public Charcoal\App\Script\ScriptInterface
# setDryRun( boolean $simulate )

Parameters

$simulate
The dry-run flag.

Returns

Charcoal\App\Script\ScriptInterface
Chainable
public boolean
# dryRun( )

Returns

boolean
public Charcoal\App\Script\ScriptInterface
# setArguments( array $arguments )

Parameters

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

Returns

Charcoal\App\Script\ScriptInterface
Chainable

Implementation of

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

Parameters

$argumentIdent
The argument identifier.
$argument
The argument options.

Returns

Charcoal\App\Script\ScriptInterface
Chainable

Throws

InvalidArgumentException
If the argument ident is not a string.

Implementation of

Charcoal\App\Script\ScriptInterface::addArgument()
public array
# arguments( )

Returns

array
$arguments

Implementation of

Charcoal\App\Script\ScriptInterface::arguments()
public array|null
# argument( string $argumentIdent )

Parameters

$argumentIdent
The argument identifier to retrieve options from.

Returns

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

Implementation of

Charcoal\App\Script\ScriptInterface::argument()
protected mixed
# argOrInput( string $argName )

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

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

Parameters

$argName
An argument identifier.

Returns

mixed
Returns the argument or prompt value.
protected mixed
# input( string $name )

Request a value from the user for the given argument.

Request a value from the user for the given argument.

Parameters

$name
An argument identifier.

Returns

mixed
Returns the prompt value.

Throws

RuntimeException
If a radio or checkbox prompt has no options.
Methods inherited from Charcoal\App\Script\ScriptInterface
run()
API documentation generated by ApiGen