Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,32 @@ This class must extends from [\Symfony\Component\Console\Command\Command](https:
<?php
namespace Vendor\Module\Console\Command;

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class ExampleCommand extends \Symfony\Component\Console\Command\Command
{
protected function configure()
{
$options = [
new \Symfony\Component\Console\Input\InputOption(
'param',
null,
\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED,
'Param description'
),
];
$this->setName('example:hello')
->setDescription('Hello world command')
->setDefinition($options);
->setDescription('Hello world command');

// Positional argument
$this->addArgument(
'myargument',
InputArgument::REQUIRED,
'Positional required argument example'
);

// Not required option
$this->addOption(
'myoption',
null,
InputOption::VALUE_OPTIONAL,
'Option example',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);

parent::configure();
}

Expand Down