Command class abstract

Framework\CLI\Command

Class Command.

Defined in libraries/cli/src/Command.php

Properties #

$console
Console instance of the current command.
$name
Command name.
$group
Command group.
$description
Command description.
$usage
Command usage.
$options
Command options.
$active
Tells if command is active.

$console

protected \Framework\CLI\Console $console

Console instance of the current command.

$name

protected string $name

Command name.

$group

protected string $group

Command group.

$description

protected string $description

Command description.

$usage

protected string $usage = 'command [options] -- [arguments]'

Command usage.

$options

protected array $options = array ( )

Command options.

$active

protected bool $active = true

Tells if command is active.

Methods #

__construct()
Command constructor.
activate()
Activate the command.
deactivate()
Deactivate the command.
getConsole()
Get console instance.
getDescription()
Get command description.
getGroup()
Get command group.
getName()
Get command name.
getOptions()
Get command options.
getUsage()
Get command usage.
isActive()
Tells if the command is active.
run()
Run the command.
setConsole()
Set console instance.
setDescription()
Set command description.
setGroup()
Set command group.
setName()
Set command name.
setOptions()
Set command options.
setUsage()
Set command usage.

__construct()

public function __construct(?\Framework\CLI\Console $console = NULL)

Command constructor.

Parameters
  • ?\Framework\CLI\Console $console

activate()

public function activate(): static

Activate the command.

Returns static

deactivate()

public function deactivate(): static

Deactivate the command.

Returns static

getConsole()

public function getConsole(): \Framework\CLI\Console

Get console instance.

Returns \Framework\CLI\Console

getDescription()

public function getDescription(): string

Get command description.

Returns string

getGroup()

public function getGroup(): ?string

Get command group.

Returns ?string

getName()

public function getName(): string

Get command name.

Returns string

getOptions()

public function getOptions(): array

Get command options.

Returns array

getUsage()

public function getUsage(): string

Get command usage.

Returns string

isActive()

public function isActive(): bool

Tells if the command is active.

Returns bool

run()

public abstract function run(): void

Run the command.

Returns void

setConsole()

public function setConsole(\Framework\CLI\Console $console): static

Set console instance.

Parameters
  • \Framework\CLI\Console $console
Returns static

setDescription()

public function setDescription(string $description): static

Set command description.

Parameters
  • string $description
Returns static

setGroup()

public function setGroup(string $group): static

Set command group.

Parameters
  • string $group
Returns static

setName()

public function setName(string $name): static

Set command name.

Parameters
  • string $name
Returns static

setOptions()

public function setOptions(array $options): static

Set command options.

Parameters
  • array $options
Returns static

setUsage()

public function setUsage(string $usage): static

Set command usage.

Parameters
  • string $usage
Returns static