{
    if (!extension_loaded($ext)) {
        echo "ERROR: The PHP extension '{$ext}' is not installed. You must " . "install it to run daemons on this machine.\n";
        exit(1);
    }
}
switch (isset($argv[1]) ? $argv[1] : 'help') {
    case 'list':
        $err = $control->executeListCommand();
        exit($err);
    case 'status':
        $err = $control->executeStatusCommand();
        exit($err);
    case 'stop':
        $pass_argv = array_slice($argv, 2);
        $err = $control->executeStopCommand($pass_argv);
        exit($err);
    case 'repository-launch-readonly':
        $need_launch = phd_load_tracked_repositories_of_type('git');
        if (!$need_launch) {
            echo "There are no repositories with tracking enabled.\n";
        } else {
            will_launch($control);
            foreach ($need_launch as $repository) {
                $name = $repository->getName();
                $callsign = $repository->getCallsign();
                $desc = "'{$name}' ({$callsign})";
                $phid = $repository->getPHID();
                echo "Launching 'git fetch' daemon on the {$desc} repository...\n";
                $control->launchDaemon('PhabricatorRepositoryGitFetchDaemon', array($phid));
            }
function must_have_extension($ext)
{
    if (!extension_loaded($ext)) {
        echo "ERROR: The PHP extension '{$ext}' is not installed. You must " . "install it to run daemons on this machine.\n";
        exit(1);
    }
}
switch (isset($argv[1]) ? $argv[1] : 'help') {
    case 'list':
        $err = $control->executeListCommand();
        exit($err);
    case 'status':
        $err = $control->executeStatusCommand();
        exit($err);
    case 'stop':
        $err = $control->executeStopCommand();
        exit($err);
    case 'repository-launch-readonly':
        $need_launch = phd_load_tracked_repositories_of_type('git');
        if (!$need_launch) {
            echo "There are no repositories with tracking enabled.\n";
        } else {
            will_launch($control);
            foreach ($need_launch as $repository) {
                $name = $repository->getName();
                $callsign = $repository->getCallsign();
                $desc = "'{$name}' ({$callsign})";
                $phid = $repository->getPHID();
                echo "Launching 'git fetch' daemon on the {$desc} repository...\n";
                $control->launchDaemon('PhabricatorRepositoryGitFetchDaemon', array($phid));
            }