Skip to content

Commit 5635ed9

Browse files
authored
[console] Add default options. (hechoendrupal#31)
1 parent 760e8e3 commit 5635ed9

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

src/ConsoleApplication.php

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Symfony\Component\DependencyInjection\ContainerInterface;
77
use Symfony\Component\Console\Input\InputInterface;
88
use Symfony\Component\Console\Output\OutputInterface;
9+
use Symfony\Component\Console\Input\InputOption;
910
use Symfony\Component\EventDispatcher\EventDispatcher;
1011
use Drupal\Console\EventSubscriber\CallCommandListener;
1112

@@ -32,6 +33,7 @@ public function __construct(
3233
$version
3334
) {
3435
$this->container = $container;
36+
$this->addOptions();
3537
parent::__construct($name, $version);
3638
}
3739

@@ -78,4 +80,88 @@ private function registerEvents()
7880
);
7981
$this->setDispatcher($dispatcher);
8082
}
83+
84+
private function addOptions()
85+
{
86+
$this->getDefinition()->addOption(
87+
new InputOption(
88+
'--env',
89+
'-e',
90+
InputOption::VALUE_OPTIONAL,
91+
$this->trans('application.options.env'), 'prod'
92+
)
93+
);
94+
$this->getDefinition()->addOption(
95+
new InputOption(
96+
'--root',
97+
null,
98+
InputOption::VALUE_OPTIONAL,
99+
$this->trans('application.options.root')
100+
)
101+
);
102+
$this->getDefinition()->addOption(
103+
new InputOption(
104+
'--no-debug',
105+
null,
106+
InputOption::VALUE_NONE,
107+
$this->trans('application.options.no-debug')
108+
)
109+
);
110+
$this->getDefinition()->addOption(
111+
new InputOption(
112+
'--learning',
113+
null,
114+
InputOption::VALUE_NONE,
115+
$this->trans('application.options.learning')
116+
)
117+
);
118+
$this->getDefinition()->addOption(
119+
new InputOption(
120+
'--generate-chain',
121+
'-c',
122+
InputOption::VALUE_NONE,
123+
$this->trans('application.options.generate-chain')
124+
)
125+
);
126+
$this->getDefinition()->addOption(
127+
new InputOption(
128+
'--generate-inline',
129+
'-i',
130+
InputOption::VALUE_NONE,
131+
$this->trans('application.options.generate-inline')
132+
)
133+
);
134+
$this->getDefinition()->addOption(
135+
new InputOption(
136+
'--generate-doc',
137+
'-d',
138+
InputOption::VALUE_NONE,
139+
$this->trans('application.options.generate-doc')
140+
)
141+
);
142+
$this->getDefinition()->addOption(
143+
new InputOption(
144+
'--target',
145+
'-t',
146+
InputOption::VALUE_OPTIONAL,
147+
$this->trans('application.options.target')
148+
)
149+
);
150+
$this->getDefinition()->addOption(
151+
new InputOption(
152+
'--uri',
153+
'-l',
154+
InputOption::VALUE_REQUIRED,
155+
$this->trans('application.options.uri')
156+
)
157+
);
158+
$this->getDefinition()->addOption(
159+
new InputOption(
160+
'--yes',
161+
'-y',
162+
InputOption::VALUE_NONE,
163+
$this->trans('application.options.yes')
164+
)
165+
);
166+
}
81167
}

0 commit comments

Comments
 (0)