/**
  * @return int|void
  */
 public function __invoke()
 {
     if (!$this->userState->isAssignedExercise()) {
         $this->output->printError("No active exercises. Select one from the menu");
         return 1;
     }
     $currentExercise = $this->userState->getCurrentExercise();
     $exercise = $this->exerciseRepository->findByName($currentExercise);
     $markDown = file_get_contents($exercise->getProblem());
     $doc = $this->markdownRenderer->render($markDown);
     $doc = str_replace('{appname}', $this->appName, $doc);
     $this->output->write($doc);
 }
Example #2
0
 /**
  * @param string $appName
  * @param string $program
  *
  * @return int|void
  */
 public function __invoke($appName, $program)
 {
     if (!file_exists($program)) {
         $this->output->printError(sprintf('Could not run. File: "%s" does not exist', $program));
         return 1;
     }
     $program = realpath($program);
     if (!$this->userState->isAssignedExercise()) {
         $this->output->printError("No active exercises. Select one from the menu");
         return 1;
     }
     $exercise = $this->exerciseRepository->findByName($this->userState->getCurrentExercise());
     $this->exerciseDispatcher->run($exercise, $program, $this->output);
 }
Example #3
0
 /**
  * @param string $appName
  * @param string $program
  *
  * @return int|void
  */
 public function __invoke($appName, $program)
 {
     if (!file_exists($program)) {
         $this->output->printError(sprintf('Could not verify. File: "%s" does not exist', $program));
         return 1;
     }
     $program = realpath($program);
     if (!$this->userState->isAssignedExercise()) {
         $this->output->printError("No active exercises. Select one from the menu");
         return 1;
     }
     $exercise = $this->exerciseRepository->findByName($this->userState->getCurrentExercise());
     $results = $this->exerciseDispatcher->verify($exercise, $program);
     if ($results->isSuccessful()) {
         $this->userState->addCompletedExercise($exercise->getName());
         $this->userStateSerializer->serialize($this->userState);
     }
     $this->resultsRenderer->render($results, $exercise, $this->userState, $this->output);
     return $results->isSuccessful() ? 0 : 1;
 }