PHP Class CraftCli\Command\Command

Inheritance: extends Symfony\Component\Console\Command\Command, implements CraftCli\Command\NeedsCraftInterface
Datei anzeigen Open project: rsanchez/craft-cli

Protected Properties

Property Type Description
$appPath string Craft app path
$basePath string Craft base path
$configPath string Craft config path
$craft Craft\ConsoleApp Craft app instance
$description string The console command description.
$input Symfony\Component\Console\Input\InputInterface The input interface implementation.
$name string The console command name.
$output Symfony\Component\Console\Style\StyleInterface The output interface implementation.
$pluginsPath string Craft plugins path
$showsDuration boolean Whether to show the command's duration after the command finishes
$storagePath string Craft storage path
$templatesPath string Craft templates path
$translationsPath string Craft translations path

Public Methods

Method Description
anticipate ( string $question, array $choices, string $default = null ) : string Prompt the user for input with auto completion.
argument ( string $key = null ) : string | array Get the value of a command argument.
ask ( string $question, string $default = null ) : string Prompt the user for input.
askWithCompletion ( string $question, array $choices, string $default = null ) : string Prompt the user for input with auto completion.
choice ( string $question, array $choices, string $default = null, mixed $attempts = null, boolean $multiple = null ) : boolean Give the user a single choice from an array of answers.
comment ( string $string ) : void Write a string as comment output.
confirm ( string $question, boolean $default = false ) : boolean Confirm a question with the user.
error ( string $string ) : void Write a string as error output.
info ( string $string ) : void Write a string as information output.
line ( string $string ) : void Write a string as standard output.
option ( string $key = null ) : string | array Get the value of a command option.
question ( string $string ) : void Write a string as question output.
run ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer Run the console command.
secret ( string $question, boolean $fallback = true ) : string Prompt the user for input but hide the answer from the console.
setAppPath ( $path )
setBasePath ( $path )
setConfigPath ( $path )
setCraft ( Craft\ConsoleApp $craft )
setEnvironment ( $environment )
setPluginsPath ( $path )
setStoragePath ( $path )
setTemplatesPath ( $path )
setTranslationsPath ( $path )
table ( array $headers, array $rows, string $style = 'default' ) : void Format input to textual table.
warn ( string $string ) : void Write a string as warning output.

Protected Methods

Method Description
configure ( ) : void Specify the arguments and options on the command.
execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : mixed Execute the console command.
fire ( ) : mixed Execute the console command.
getArguments ( ) : array Get the console command arguments.
getOptions ( ) : array Get the console command options.
suppressOutput ( callable $callback ) : mixed Useful for supressing log messages

Method Details

anticipate() public method

Prompt the user for input with auto completion.
public anticipate ( string $question, array $choices, string $default = null ) : string
$question string
$choices array
$default string
return string

argument() public method

Get the value of a command argument.
public argument ( string $key = null ) : string | array
$key string
return string | array

ask() public method

Prompt the user for input.
public ask ( string $question, string $default = null ) : string
$question string
$default string
return string

askWithCompletion() public method

Prompt the user for input with auto completion.
public askWithCompletion ( string $question, array $choices, string $default = null ) : string
$question string
$choices array
$default string
return string

choice() public method

Give the user a single choice from an array of answers.
public choice ( string $question, array $choices, string $default = null, mixed $attempts = null, boolean $multiple = null ) : boolean
$question string
$choices array
$default string
$attempts mixed
$multiple boolean
return boolean

comment() public method

Write a string as comment output.
public comment ( string $string ) : void
$string string
return void

configure() protected method

Specify the arguments and options on the command.
protected configure ( ) : void
return void

confirm() public method

Confirm a question with the user.
public confirm ( string $question, boolean $default = false ) : boolean
$question string
$default boolean
return boolean

error() public method

Write a string as error output.
public error ( string $string ) : void
$string string
return void

execute() protected method

Execute the console command.
protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : mixed
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
return mixed

fire() protected method

Execute the console command.
protected fire ( ) : mixed
return mixed

getArguments() protected method

Get the console command arguments.
protected getArguments ( ) : array
return array

getOptions() protected method

Get the console command options.
protected getOptions ( ) : array
return array

info() public method

Write a string as information output.
public info ( string $string ) : void
$string string
return void

line() public method

Write a string as standard output.
public line ( string $string ) : void
$string string
return void

option() public method

Get the value of a command option.
public option ( string $key = null ) : string | array
$key string
return string | array

question() public method

Write a string as question output.
public question ( string $string ) : void
$string string
return void

run() public method

Run the console command.
public run ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
return integer

secret() public method

Prompt the user for input but hide the answer from the console.
public secret ( string $question, boolean $fallback = true ) : string
$question string
$fallback boolean
return string

setAppPath() public method

public setAppPath ( $path )

setBasePath() public method

public setBasePath ( $path )

setConfigPath() public method

public setConfigPath ( $path )

setCraft() public method

public setCraft ( Craft\ConsoleApp $craft )
$craft Craft\ConsoleApp

setEnvironment() public method

public setEnvironment ( $environment )

setPluginsPath() public method

public setPluginsPath ( $path )

setStoragePath() public method

public setStoragePath ( $path )

setTemplatesPath() public method

public setTemplatesPath ( $path )

setTranslationsPath() public method

public setTranslationsPath ( $path )

suppressOutput() protected method

Useful for supressing log messages
protected suppressOutput ( callable $callback ) : mixed
$callback callable
return mixed

table() public method

Format input to textual table.
public table ( array $headers, array $rows, string $style = 'default' ) : void
$headers array
$rows array
$style string
return void

warn() public method

Write a string as warning output.
public warn ( string $string ) : void
$string string
return void

Property Details

$appPath protected_oe property

Craft app path
protected string $appPath
return string

$basePath protected_oe property

Craft base path
protected string $basePath
return string

$configPath protected_oe property

Craft config path
protected string $configPath
return string

$craft protected_oe property

Craft app instance
protected ConsoleApp,Craft $craft
return Craft\ConsoleApp

$description protected_oe property

The console command description.
protected string $description
return string

$input protected_oe property

The input interface implementation.
protected InputInterface,Symfony\Component\Console\Input $input
return Symfony\Component\Console\Input\InputInterface

$name protected_oe property

The console command name.
protected string $name
return string

$output protected_oe property

The output interface implementation.
protected StyleInterface,Symfony\Component\Console\Style $output
return Symfony\Component\Console\Style\StyleInterface

$pluginsPath protected_oe property

Craft plugins path
protected string $pluginsPath
return string

$showsDuration protected_oe property

Whether to show the command's duration after the command finishes
protected bool $showsDuration
return boolean

$storagePath protected_oe property

Craft storage path
protected string $storagePath
return string

$templatesPath protected_oe property

Craft templates path
protected string $templatesPath
return string

$translationsPath protected_oe property

Craft translations path
protected string $translationsPath
return string