symfony command options code example
Example: symfony create command
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
class CreateUserCommand extends Command
{
public function __construct(bool $requirePassword = false)
{
$this->requirePassword = $requirePassword;
parent::__construct();
}
protected function configure()
{
$this
->addArgument('password', $this->requirePassword ? InputArgument::REQUIRED : InputArgument::OPTIONAL, 'User password')
;
}
}