Execute command

@param InputInterface  $input
@param OutputInterface $output

@return int 0 if everything went fine, or an error code
19439
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);
        $aliasId = $input->getArgument('aliasId');
        $limit = 20;

        $objectManager = $this->getContainer()->get('object_manager');
        $siteClass = $this->getContainer()->getParameter('open_orchestra_model.document.site.class');
        $nodeClass = $this->getContainer()->getParameter('open_orchestra_model.document.node.class');

        $site = $objectManager->getRepository($siteClass)
            ->findOneBy(array(
                'aliases.'.$aliasId => array('$exists' => true)
                )
            );

        if($site instanceof $siteClass) {
            $aliases = $site->getAliases();
            if ($aliases->containsKey($aliasId)) {
                $siteId = $site->getSiteId();
                $language = $aliases[$aliasId]->getLanguage();
                $lastAlias = true;
                foreach ($aliases as $key => $alias) {
                    if ($alias->getLanguage() == $language && $key != $aliasId) {
                        $lastAlias = false;
                    }
                }
            }

            if ($lastAlias) {
                $io->comment('Remove use references of nodes');

                $deleteSiteTools = $this->getContainer()->get('open_orchestra_backoffice.command.orchestra_delete_site_tools');

                $nodes = $objectManager->createQueryBuilder($nodeClass)
                    ->field('siteId')->equals($siteId)
                    ->field('language')->equals($language)
                    ->getQuery()->execute();

                $usedInNodes = $deleteSiteTools->findUsageReferenceInOtherSite($siteId, $nodes);
                if (!empty($usedInNodes)) {
                    $io->section('Usage of nodes in other sites');
                    $deleteSiteTools->displayUsedReferences($io, $usedInNodes);
                    throw new \RuntimeException('You should remove usage of nodes before remove alias ' . $aliasId);
                }

                $count = count($nodes);

                for ($skip = 0; $skip < $count; $skip += $limit) {
                    $nodes = $objectManager->createQueryBuilder($nodeClass)
                        ->field('siteId')->equals($siteId)
                        ->field('language')->equals($language)
                        ->sort('id', 'asc')
                        ->skip($skip)
                        ->limit($limit)
                        ->getQuery()->execute();
                    foreach ($nodes as $node) {
                        $this->getContainer()->get('open_orchestra_backoffice.reference.manager')->removeReferencesToEntity($node);
                    }
                    $objectManager->clear();
                }

                $io->comment('Remove nodes');
                $objectManager->createQueryBuilder($nodeClass)
                    ->field('siteId')->equals($siteId)
                    ->field('language')->equals($language)
                    ->remove()->getQuery()->execute();
            }

            $site->removeAlias($aliases->get($aliasId));
            $objectManager->persist($site);
            $objectManager->flush();

        }
    }
915365
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->output = $output;
        $config = $this->parameters;
        $recursive = $input->getOption('recursive');
        $machine = $input->getOption('machine') ? $config->get('dotfiles.machine_name') : 'defaults';
        $backupDir = $config->get('dotfiles.backup_dir')."/src/$machine/home";
        $sourcePath = $input->getArgument('path');

        // detect source path
        $originPath = $this->detectPath($sourcePath);
        $relativePath = Toolkit::getRelativePath($originPath);
        if (0 === strpos($relativePath, '.')) {
            $relativePath = substr($relativePath, 1);
        }
        $relativePath = str_replace('.'.$sourcePath, $sourcePath, $relativePath);
        $targetPath = $backupDir.'/'.$relativePath;

        Toolkit::ensureDir($backupDir);

        $basename = basename($sourcePath);
        if (0 === strpos($basename, '.')) {
            $targetPath = str_replace('.'.$sourcePath, $basename, $targetPath);
        }

        if (is_dir($originPath)) {
            $this->doAddDir($originPath, $targetPath, $recursive);
        } else {
            $this->doAddFile($originPath, $targetPath);
        }
    }
1131188
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('Looking for updates...');

        $manager         = $this->createManager($output);
        $version         = $input->getArgument('version')
            ? $input->getArgument('version')
            : $this->getApplication()->getVersion();
        $allowMajor      = $input->getOption('major');
        $allowPreRelease = $input->getOption('pre');

        if (strpos($version, 'v') === 0) {
            // strip v tag from phar version for self-update
            $version = str_replace('v', '', $version);
        }

        $this->updateCurrentVersion($manager, $version, $allowMajor, $allowPreRelease, $output);

        return 0;
    }
32411
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->init($input, $output);

        $this->force_prompt();
                
        $this->publish_packages($this->get_packages());
        
        // Feedback how many files were copied.
        if (\count($this->copied)) {
            $this->output->writeln(
                \sprintf(
                    "\n<info>Published %d %s successfully:\n%s</info>",
                    \count($this->copied),
                    _n('file', 'files', \count($this->copied)),
                    \implode($this->copied, "\n")
                )
            );
            exit;
        }
        
        $this->output->writeln("\n<info>Nothing needed to be published</info>");
    }
515278
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
        $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
        $errOutput->setVerbosity(OutputInterface::VERBOSITY_NORMAL);

        $interval = NumberUtils::bound($input->getOption('interval'), 1, 60);
        $context = json_decode($input->getOption('context') ?: '{}', true);
        $context['tenant_id'] = (string)$input->getOption('tenant-id');
        $streamId = StreamId::fromString($input->getArgument('stream-id'));

        $eventStore = $this->getPbjx()->getEventStore();
        $since = Microtime::create();

        while (true) {
            $event = null;
            $slice = $eventStore->getStreamSlice($streamId, $since, 25, true, false, $context);

            foreach ($slice as $event) {
                try {
                    echo json_encode($event) . PHP_EOL;
                } catch (\Throwable $e) {
                    $errOutput->writeln($e->getMessage());
                }
            }

            if ($event instanceof Event) {
                $since = $event->get('occurred_at');
            }

            sleep($interval);
        }
    }
1132827
protected function execute(InputInterface $input, OutputInterface $output) : int
    {
        parent::execute($input, $output);

        $this->queue->consume(function (Message $message) {
            return $this->consumeCallback($message);
        });

        return $this->sendExitCode();
    }
868029
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->initializeLicenser($input, $output);

        $sources = $input->getArgument('sources');

        $this->licenser->process(
            $sources,
            (bool) $input->getOption('replace-existing'),
            (bool) $input->getOption('dry-run')
        );

        return 0;
    }
305470
public function execute(InputInterface $input, OutputInterface $output)
    {
        $host = $input->getArgument('host');
        $ip = $input->getArgument('ip');

        $this->hostFile->add($host, $ip);

        $output->writeLn("\"$ip $host\" was added to file.");
    }
385215
protected function execute(InputInterface $input, OutputInterface $output) : int
    {
        $io         = $this->getIO($input, $output);
        $config     = $this->getConfig($this->configFile, true);
        $repository = new Repository($this->repositoryPath);
        $arguments  = new Config\Options($input->getArguments());

        /** @var \CaptainHook\App\Runner\Hook $hook */
        $class = '\\CaptainHook\\App\\Runner\\Hook\\' . Util::getHookCommand($this->name);
        $hook  = new $class($io, $config, $repository, $arguments);


        $hook->run();
        return 0;
    }
850737
protected function execute(InputInterface $input, OutputInterface $output)
    {
        return $this->getRunner($input, $output)->run() ? 0 : -1;
    }
311377
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $filename = $input->getArgument('filename');
        $key = $input->getArgument('key');
        $yaml_parsed = $this->loadYamlFile($filename);
        if (!$yaml_parsed) {
            // Exit with a status of 1.
            return 1;
        }

        $data = new Data($yaml_parsed);
        if (!$this->checkKeyExists($data, $key)) {
            return 1;
        }

        $value = $data->get($key);
        $output->writeln(trim(Yaml::dump($value)));
    }
647715
protected function execute(InputInterface $input, OutputInterface $output)
  {
    $name = $input->getArgument('name');
    $class = implode('', array_map('ucfirst', explode('_', str_replace(':', '_', $name))));

    if ($this->add($name, $class)) {
      return $output->writeln('<info>Command "' . $class . '" has been successfully created.</info>');
    }

    return $output->writeln('Command "' . $class . '" already exists.');
  }
840413
protected function execute( InputInterface $input, OutputInterface $output ) {
		$this->output = $output;
		$this->input = $input;
		$path = $this->setup();
		if ( is_int( $path ) ) {
			return $path;
		}
		$err = $this->loadConfig( $path );
		if ( is_int( $err ) ) {
			return $err;
		}

		$output->writeln( "Processing $path..." );
		$bad = $this->checkPath( $path );
		$output->write( "\n" );
		if ( $bad ) {
			foreach ( $bad as $file ) {
				$output->writeln( "Error: {$file->getPathname()} should not be executable" );
			}
			return 1;
		} else {
			$output->writeln( 'All good!' );
			return 0;
		}
	}
239355
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->requireConfig();

        $output->writeln('Starting <fg=blue>Magallanes</>');
        $output->writeln('');

        $output->writeln(sprintf('<comment>%s</comment>', var_export($this->runtime->getConfiguration(), true)));

        $output->writeln('');
        $output->writeln('Finished <fg=blue>Magallanes</>');

        return 0;
    }
193480
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->injectOutputIntoLogger($output, $this->logger);
        $this->logger->info('Getting database metadata.');
        $databaseAdapter = $this->databaseAdapterManager->getAdapter($input->getOption('adapter'));
        $databases = $databaseAdapter->getDatabaseMetadata();
        $databases = $this->sort($databases, $input->getOption('sort'), $input->getOption('reverse-sort'));
        $databases = $this->format(
            $databases,
            $input->getOption('unit'),
            $input->getOption('precision')
        );

        $outputTable = new Table($output);
        $outputTable
            ->setHeaders(array('Database', 'Size in ' . $input->getOption('unit')));
        foreach ($databases as $name => $database) {
            $outputTable->addRow([$name, $database['size']]);
        }
        $outputTable->render();
        return 0;
    }
818425
protected function execute(InputInterface $input, OutputInterface $output): int
    {
        if (null === $path = $input->getOption('path')) {
            $config = $this->getConfig()->jsonSerialize();
        } else {
            $config = $this->getConfig($path);
        }
        $output->writeln(Yaml::dump($config));
        return 0;
    }
561848
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!($this->lock())) {
            $output->writeln('The command is already running in another process.');

            return 0;
        }

        $producer = $this->getContainer()->get('enqueue.producer');

        // @todo iterate through all instead of limiting to 500
        $queueItems = $this->queueItemRepository->findBy([
            'status' => QueueItem::STATUS_PENDING,
        ], [], 500);

        foreach ($queueItems as $queueItem) {
            $queueItem->setStatus(QueueItem::STATUS_PROCESSING);
            $producer->sendEvent($queueItem->getType(), $queueItem->getIdentifier());

            $this->queueItemRepository->save($queueItem);
        }

        return 0;
    }