@@ -169,13 +169,13 @@ public function setBgColour(string $colour): void
169169 $ this ->bgColour = $ colour ;
170170 }
171171
172- public function configure (): ContainerInterface
172+ public function configure (bool $ debugMode = false ): ContainerInterface
173173 {
174174 if ($ this ->container instanceof ContainerInterface) {
175175 return $ this ->container ;
176176 }
177177
178- $ container = $ this ->getContainer ();
178+ $ container = $ this ->getContainer ($ debugMode );
179179
180180 foreach ($ this ->exercises as $ exercise ) {
181181 if (false === $ container ->has ($ exercise )) {
@@ -221,10 +221,20 @@ public function configure(): ContainerInterface
221221 */
222222 public function run (): int
223223 {
224- $ container = $ this ->configure ();
224+ $ args = $ _SERVER ['argv ' ] ?? [];
225+
226+ $ debug = any ($ args , function (string $ arg ) {
227+ return $ arg === '--debug ' ;
228+ });
229+
230+ $ args = array_values (array_filter ($ args , function (string $ arg ) {
231+ return $ arg !== '--debug ' ;
232+ }));
233+
234+ $ container = $ this ->configure ($ debug );
225235
226236 try {
227- $ exitCode = $ container ->get (CommandRouter::class)->route ();
237+ $ exitCode = $ container ->get (CommandRouter::class)->route ($ args );
228238 } catch (MissingArgumentException $ e ) {
229239 $ container
230240 ->get (OutputInterface::class)
@@ -261,9 +271,10 @@ public function run(): int
261271 }
262272
263273 /**
274+ * @param bool $debugMode
264275 * @return Container
265276 */
266- private function getContainer (): Container
277+ private function getContainer (bool $ debugMode ): Container
267278 {
268279 $ containerBuilder = new ContainerBuilder ();
269280 $ containerBuilder ->addDefinitions (
@@ -276,6 +287,7 @@ private function getContainer(): Container
276287 $ containerBuilder ->addDefinitions (
277288 [
278289 'workshopTitle ' => $ this ->workshopTitle ,
290+ 'debugMode ' => $ debugMode ,
279291 'exercises ' => $ this ->exercises ,
280292 'workshopLogo ' => $ this ->logo ,
281293 'bgColour ' => $ this ->bgColour ,
0 commit comments