protected function buildCommand(CommandPluginInterface $commandPlugin)
    {
        $definition = $commandPlugin->getCommandDefinition();
        $argumentsAndOptions = [];

        $consoleComand = new Command($definition->getName());
        $consoleComand->setDescription($definition->getDescription());
        $consoleComand->setHelp($definition->getHelp());

        foreach ($definition->getArguments() as list($name, $mode, $description, $defaultValue)) {
            $argumentsAndOptions[] = new InputArgument($name, $mode, $description, $defaultValue);
        }

        foreach ($definition->getOptions() as list($name, $shortcut, $mode, $description, $defaultValue)) {
            $argumentsAndOptions[] = new InputOption($name, $shortcut, $mode, $description, $defaultValue);
        }

        $consoleComand->setDefinition($argumentsAndOptions);
        $consoleComand->setCode(function (InputInterface $input, OutputInterface $output) use ($commandPlugin, $consoleComand) {
            $io = new ConsoleIO($input, $output);
            $arguments = $input->getArguments();
            $options = $input->getOptions();

            $commandPlugin->setCommandEnvironment(new SymfonyCommandEnvironment($consoleComand, $output));
            $commandPlugin->executeCommand($io, $arguments, $options);
        });

        return $consoleComand;
    }