public function handle(Args $args)
    {
        $target = $args->getArgument('target');

        if (!in_array($target, self::$targets)) {
            throw new RuntimeException(sprintf(
                'Invalid build target "%s". Expected one of: "%s"',
                $target,
                implode('", "', self::$targets)
            ));
        }

        if ('all' === $target || 'factory' === $target) {
            $this->factoryManager->autoGenerateFactoryClass();
        }

        if ('all' === $target || 'repository' === $target) {
            $this->repoManager->clearRepository();
            $this->repoManager->buildRepository();
        }

        if ('all' === $target || 'discovery' === $target) {
            $this->discoveryManager->clearDiscovery();
            $this->discoveryManager->buildDiscovery();
            $this->discoveryManager->removeObsoleteDisabledBindingDescriptors();
        }

        return 0;
    }