private function registerCommand(
        $name, $data, \Console_CommandLine_Command $parent = null)
    {
        $command = isset($data['command']) ? $data['command'] : $data;
        if (null === $parent) {
            $cmd = $this->addCommand($name, $command);
        } else {
            $cmd = $parent->addCommand($name, $command);
        }
        // command arguments
        $args = isset($command['arguments']) ? $command['arguments'] : array();
        foreach ($args as $name => $argument) {
            $cmd->addArgument($name, $argument);
        }
        // command options
        $opts = isset($command['options']) ? $command['options'] : array();
        foreach ($opts as $name => $option) {
            $cmd->addOption($name, $option);
        }
        // commands actions (sub-commands)
        $subs = isset($command['commands']) ? $command['commands'] : array();
        foreach ($subs as $name => $data) {
            $this->registerCommand($name, $data, $cmd);
        }
    }