public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $daemon = new PhabricatorFactDaemon(array());
     $daemon->setVerbose(true);
     $daemon->setEngines(PhabricatorFactEngine::loadAllEngines());
     $iterators = array(new PhabricatorFactUpdateIterator(new DifferentialRevision()));
     foreach ($iterators as $iterator) {
         $daemon->processIterator($iterator);
     }
     $daemon->processAggregates();
     return 0;
 }
 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $reset = $args->getArg('reset');
     if ($reset) {
         foreach ($reset as $name) {
             $cursor = id(new PhabricatorFactCursor())->loadOneWhere('name = %s', $name);
             if ($cursor) {
                 $console->writeOut("%s\n", pht("Resetting cursor %s...", $name));
                 $cursor->delete();
             } else {
                 $console->writeErr("%s\n", pht("Cursor %s does not exist or is already reset.", $name));
             }
         }
         return 0;
     }
     $iterator_map = PhabricatorFactDaemon::getAllApplicationIterators();
     if (!$iterator_map) {
         $console->writeErr("%s\n", pht("No cursors."));
         return 0;
     }
     $cursors = id(new PhabricatorFactCursor())->loadAllWhere('name IN (%Ls)', array_keys($iterator_map));
     $cursors = mpull($cursors, 'getPosition', 'getName');
     foreach ($iterator_map as $iterator_name => $iterator) {
         $console->writeOut("%s (%s)\n", $iterator_name, idx($cursors, $iterator_name, 'start'));
     }
     return 0;
 }
 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $daemon = new PhabricatorFactDaemon(array());
     $daemon->setVerbose(true);
     $daemon->setEngines(PhabricatorFactEngine::loadAllEngines());
     $iterators = PhabricatorFactDaemon::getAllApplicationIterators();
     $selected = $args->getArg('iterator');
     if ($selected) {
         $use = array();
         foreach ($selected as $iterator_name) {
             if (isset($iterators[$iterator_name])) {
                 $use[$iterator_name] = $iterators[$iterator_name];
             } else {
                 $console->writeErr("%s\n", pht("Iterator '%s' does not exist.", $iterator_name));
             }
         }
         $iterators = $use;
     }
     foreach ($iterators as $iterator_name => $iterator) {
         if ($args->getArg('all')) {
             $daemon->processIterator($iterator);
         } else {
             $daemon->processIteratorWithCursor($iterator_name, $iterator);
         }
     }
     if (!$args->getArg('skip-aggregates')) {
         $daemon->processAggregates();
     }
     return 0;
 }