protected function listCommands(InputInterface $input, OutputInterface $output) { $filter = $input->getArgument(1, NULL); $message = $filter === NULL ? '' : ' in namespace [' . $filter . ']'; $output->writeLine("Available commands%s:", $message); $output->writeLine(''); foreach ($this->commands as $namespace => $cmd) { if ($filter !== NULL && $namespace != $filter) { continue; } $output->writeLine($namespace . ':'); foreach ($cmd as $name => $command) { $output->writeLine(' %s - %s', $name, $command->getDescription()); } $output->writeLine(''); } if ($filter === NULL) { $output->writeLine('help - List all available commands.'); $output->writeLine('exit - Terminate the K2 shell.'); } }