Skip to content

Commit 5c7ab03

Browse files
committed
Check solution file exists in run command
1 parent 27f65b6 commit 5c7ab03

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Command/RunCommand.php

+7
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
namespace PhpSchool\PhpWorkshop\Command;
66

7+
use PhpSchool\PhpWorkshop\Check\FileExistsCheck;
78
use PhpSchool\PhpWorkshop\ExerciseDispatcher;
89
use PhpSchool\PhpWorkshop\ExerciseRepository;
910
use PhpSchool\PhpWorkshop\Input\Input;
1011
use PhpSchool\PhpWorkshop\Output\OutputInterface;
12+
use PhpSchool\PhpWorkshop\Result\Success;
1113
use PhpSchool\PhpWorkshop\UserState;
1214

1315
/**
@@ -60,6 +62,11 @@ public function __construct(
6062
*/
6163
public function __invoke(Input $input): void
6264
{
65+
if (!file_exists($input->getRequiredArgument('program'))) {
66+
$this->output->printError(sprintf('File: "%s" does not exist', $input->getRequiredArgument('program')));
67+
return;
68+
}
69+
6370
$exercise = $this->exerciseRepository->findByName($this->userState->getCurrentExercise());
6471
$this->exerciseDispatcher->run($exercise, $input, $this->output);
6572
}

0 commit comments

Comments
 (0)