addOption("list", null, InputOption::VALUE_NONE, "List the available scripts"); $this->addArgument("script", InputArgument::OPTIONAL, "The script too run (see --list)"); $this->addArgument("args", InputArgument::OPTIONAL|InputArgument::IS_ARRAY, "Arguments to the script"); } protected function execute(InputInterface $input, OutputInterface $output) { $env = $this->getEnvironment(); $args = $input->getArgument('args'); if ($input->getOption("list") || empty($input->getArgument("script"))) { $scripts = $env->getDefinedScripts(); if (count($scripts) > 0) { $output->writeln("Defined scripts:"); $output->writeln("- ".join("\n- ",$scripts)); } else { $output->writeln("No scripts defined."); } return Command::SUCCESS; } elseif ($script = $input->getArgument('script')) { $env->runScript($script, $args, $input, $output); } return Command::SUCCESS; } }