File tree Expand file tree Collapse file tree 1 file changed +21
-10
lines changed
1. Magento Architecture and Customization Techniques Expand file tree Collapse file tree 1 file changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -48,21 +48,32 @@ This class must extends from [\Symfony\Component\Console\Command\Command](https:
4848<?php
4949namespace Vendor\Module\Console\Command;
5050
51+ use Symfony\Component\Console\Input\InputArgument;
52+ use Symfony\Component\Console\Input\InputOption;
53+
5154class ExampleCommand extends \Symfony\Component\Console\Command\Command
5255{
5356 protected function configure()
5457 {
55- $options = [
56- new \Symfony\Component\Console\Input\InputOption(
57- 'param',
58- null,
59- \Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED,
60- 'Param description'
61- ),
62- ];
6358 $this->setName('example:hello')
64- ->setDescription('Hello world command')
65- ->setDefinition($options);
59+ ->setDescription('Hello world command');
60+
61+ // Positional argument
62+ $this->addArgument(
63+ 'myargument',
64+ InputArgument::REQUIRED,
65+ 'Positional required argument example'
66+ );
67+
68+ // Not required option
69+ $this->addOption(
70+ 'myoption',
71+ null,
72+ InputOption::VALUE_OPTIONAL,
73+ 'Option example',
74+ ScopeConfigInterface::SCOPE_TYPE_DEFAULT
75+ );
76+
6677 parent::configure();
6778 }
6879
You can’t perform that action at this time.
0 commit comments