trackingService)) { return false; } return $this instanceof Command; } protected function getReportParameter( InputInterface $input, OutputInterface $output, $default = 'tracking_service.youtrack.report.report' ) { if (! $this->checkContext()) { return Command::FAILURE; } $reports = $this->trackingService->listReports(); // Could just parse a csv file or actually get workItems from youtrack ... if ($input->hasParameterOption('--report') || $input->hasParameterOption('-r')) { if (! $report_id = $input->getOption('report')) { // @TODO Make selection nicer. // QuestionHelper: https://symfony.com/doc/current/components/console/helpers/questionhelper.html $helper = $this->getHelper('question'); $question = new ChoiceQuestion('Select report:', $reports); $question ->setErrorMessage('Report %s does not exist!') ->setAutocompleterValues($reports); $report_id = $helper->ask($input, $output, $question); $output->writeln('Report ' . $report_id . ' selected.'); } // If parameter option is not recognised check if report name was given. if (! isset($reports[$report_id])) { if (! isset(array_flip($reports)[$report_id])) { $output->writeln('Non-existing report ' . $report_id . '. Exiting.'); return Command::FAILURE; } $report_id = array_flip($reports)[$report_id]; } $this->trackingService->setReportId($report_id); } elseif ($report_id = $this->config->get($default)) { // If report is not set, try getting default report from configuration. // This is dependant on the config. $this->trackingService->setReportId($report_id); } $this->trackingService->setReportName(); } protected function getReportCsvFilePath( InputInterface $input, OutputInterface $output, ?string $default = 'tracking_service.youtrack.report.report' ): ?string { if (! $file = $input->getOption('file')) { $this->getReportParameter($input, $output, $default); $report_id = $this->trackingService->getReportId(); $cache_clear_status = $this->trackingService->clearReportCache($report_id); if ($output->isVerbose()) { $output->writeln("Report {$report_id} cache cleared, status: {$cache_clear_status}"); } $file = $this->trackingService->downloadReport($report_id); if ($output->isVerbose()) { $output->writeln("Csv file downloaded to: {$file}"); } } else { $this->trackingService->setReportName($file); } return $file; } }