private function generateCommand($namespace, \ReflectionMethod $method)
    {
        $factory = DocBlockFactory::createInstance();

        $docBlock = $factory->create($method->getDocComment());

        $methodShortName = $method->getShortName();

        $command = new Command($namespace . ':' . $this->dash($methodShortName));

        $cmdExceptions = array();

        if (isset($this->cmdExceptions[$namespace])) {
            if (isset($this->cmdExceptions[$namespace][$methodShortName])) {
                $cmdExceptions = $this->cmdExceptions[$namespace][$methodShortName];
            }
        }

        $params   = $docBlock->getTagsByName('param');
        $aliases  = $docBlock->getTagsByName('alias');
        $disabled = $docBlock->getTagsByName('disabled');

        if (!empty($disabled)) {
            // restrict some public Api methods
            $command->disable();
        } else {
            if (!empty($aliases)) {
                $names = array();
                foreach ($aliases as $aliasTag) {
                    $names[] = $namespace . ':' . (string) $aliasTag->getDescription();
                }
                $name = array_shift($names);
                // rename command with the first alias
                $command->setName($name);
                // others @alias are really some command aliases
                $command->setAliases($names);
            }

            $command->setDefinition(
                $this->buildDefinition($namespace, $method, $params, $cmdExceptions)
            );
            $command->setDescription($docBlock->getSummary());
            $command->setCode($this->createCode($namespace, $method));
        }
        return $command;
    }