/** * Execute the command. * * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { // We don't need moodle for getting value. if ($value = $input->getOption('value')) { switch ($value) { case 'version': $output->writeln(\moodlehq\behat_2jmx\util::get_tool_version()); break; case 'moodlepath': $output->writeln(util::get_moodle_path()); break; case 'datapath': $output->writeln(util::get_data_path()); break; default: $output->writeln('<error>Not a valid option.</error><info> Should be wither version|moodlepath|datapath</info>'); return 1; break; } return 0; } // Describe this script. define('PERFORMANCE_SITE_GENERATOR', true); define('CLI_SCRIPT', true); define('NO_OUTPUT_BUFFERING', true); define('IGNORE_COMPONENT_CACHE', true); // Load moodle config and all classes. $moodlepath = util::get_moodle_path(); // Autoload files and ensure we load moodle config, as we will be using moodle code for behat context. require_once $moodlepath . '/config.php'; require_once __DIR__ . '/inc.php'; raise_memory_limit(MEMORY_HUGE); $status = false; // Do action. $behat2jmx = new \moodlehq\behat_2jmx\generator(); $testplan = $input->getOption('testplan'); $proxyurl = $input->getOption('proxyurl'); // make sure proxyport and proxy url is provided. if (empty($proxyurl) || empty($testplan)) { $output->write($this->getHelp(), true); return 1; } $status = $behat2jmx->create_test_plan(strtolower($testplan), $proxyurl, $input->getOption('proxyport'), $input->getOption('force')); return $status; }