Argument#

Meritum\Cli\Command\Argument

Returned by Command::addArgument(). Configures a single positional argument on a command. Arguments are required by default.

Methods#

public function optional(mixed $default = null): self;

Makes the argument optional. If the user does not supply a value, $default is used.

public function array(): self;

Marks the argument as an array. The user can provide multiple values; $io->argument() returns an array.

public function description(string $description): self;

Short description shown in help output.

public function suggest(string ...$suggestions): self;

Provides shell completion suggestions for this argument.

Example#

// Required
$this->addArgument('path')
     ->description('Path to the target file');

// Optional with default
$this->addArgument('env')
     ->description('Target environment')
     ->optional('production')
     ->suggest('production', 'staging', 'local');

// Array argument
$this->addArgument('files')
     ->description('Files to process')
     ->array();