当前位置: 首页>>代码示例>>PHP>>正文


PHP PhutilArgumentParser::parse方法代码示例

本文整理汇总了PHP中PhutilArgumentParser::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP PhutilArgumentParser::parse方法的具体用法?PHP PhutilArgumentParser::parse怎么用?PHP PhutilArgumentParser::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhutilArgumentParser的用法示例。


在下文中一共展示了PhutilArgumentParser::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dirname

#!/usr/bin/env php
<?php 
$root = dirname(dirname(dirname(dirname(__FILE__))));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('test client for Aphlict server');
$args->setSynopsis(<<<EOHELP
**aphlict_test_client.php** [__options__]
    Connect to the Aphlict server configured in the Phabricator config.

EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'server', 'param' => 'uri', 'default' => PhabricatorEnv::getEnvConfig('notification.client-uri'), 'help' => 'Connect to __uri__ instead of the default server.')));
$console = PhutilConsole::getConsole();
$errno = null;
$errstr = null;
$uri = $args->getArg('server');
$uri = new PhutilURI($uri);
$uri->setProtocol('tcp');
$console->writeErr("Connecting...\n");
$socket = stream_socket_client($uri, $errno, $errstr);
if (!$socket) {
    $console->writeErr("Unable to connect to Aphlict (at '{$uri}'). Error #{$errno}: {$errstr}");
    exit(1);
} else {
    $console->writeErr("Connected.\n");
}
$io_channel = new PhutilSocketChannel($socket);
$proto_channel = new PhutilJSONProtocolChannel($io_channel);
$json = new PhutilJSON();
开发者ID:denghp,项目名称:phabricator,代码行数:31,代码来源:aphlict_test_client.php

示例2: microtime

$ssh_start_time = microtime(true);
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$ssh_log = PhabricatorSSHLog::getLog();
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('execute SSH requests'));
$args->setSynopsis(<<<EOSYNOPSIS
**ssh-exec** --phabricator-ssh-user __user__ [--ssh-command __commmand__]
**ssh-exec** --phabricator-ssh-device __device__ [--ssh-command __commmand__]
    Execute authenticated SSH requests. This script is normally invoked
    via SSHD, but can be invoked manually for testing.

EOSYNOPSIS
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'phabricator-ssh-user', 'param' => 'username', 'help' => pht('If the request authenticated with a user key, the name of the ' . 'user.')), array('name' => 'phabricator-ssh-device', 'param' => 'name', 'help' => pht('If the request authenticated with a device key, the name of the ' . 'device.')), array('name' => 'phabricator-ssh-key', 'param' => 'id', 'help' => pht('The ID of the SSH key which authenticated this request. This is ' . 'used to allow logs to report when specific keys were used, to make ' . 'it easier to manage credentials.')), array('name' => 'ssh-command', 'param' => 'command', 'help' => pht('Provide a command to execute. This makes testing this script ' . 'easier. When running normally, the command is read from the ' . 'environment (%s), which is populated by sshd.', 'SSH_ORIGINAL_COMMAND'))));
try {
    $remote_address = null;
    $ssh_client = getenv('SSH_CLIENT');
    if ($ssh_client) {
        // This has the format "<ip> <remote-port> <local-port>". Grab the IP.
        $remote_address = head(explode(' ', $ssh_client));
        $ssh_log->setData(array('r' => $remote_address));
    }
    $key_id = $args->getArg('phabricator-ssh-key');
    if ($key_id) {
        $ssh_log->setData(array('k' => $key_id));
    }
    $user_name = $args->getArg('phabricator-ssh-user');
    $device_name = $args->getArg('phabricator-ssh-device');
    $user = null;
开发者ID:JohnnyEstilles,项目名称:phabricator,代码行数:31,代码来源:ssh-exec.php

示例3: dirname

#!/usr/bin/env php
<?php 
/*
 * Copyright 2012 Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
require_once dirname(dirname(__FILE__)) . '/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'quiet', 'help' => 'Do not print status messages to stdout.'), array('name' => 'skip-hello', 'help' => 'Do not send "capability" message when clients connect. ' . 'Clients must be configured not to expect the message. ' . 'This deviates from the Mercurial protocol, but slightly ' . 'improves performance.'), array('name' => 'do-not-daemonize', 'help' => 'Remain in the foreground instead of daemonizing.'), array('name' => 'client-limit', 'param' => 'limit', 'help' => 'Exit after serving __limit__ clients.'), array('name' => 'idle-limit', 'param' => 'seconds', 'help' => 'Exit after __seconds__ spent idle.'), array('name' => 'repository', 'wildcard' => true)));
$repo = $args->getArg('repository');
if (count($repo) !== 1) {
    throw new Exception("Specify exactly one working copy!");
}
$repo = head($repo);
id(new ArcanistHgProxyServer($repo))->setQuiet($args->getArg('quiet'))->setClientLimit($args->getArg('client-limit'))->setIdleLimit($args->getArg('idle-limit'))->setDoNotDaemonize($args->getArg('do-not-daemonize'))->setSkipHello($args->getArg('skip-hello'))->start();
开发者ID:rafikk,项目名称:arcanist,代码行数:27,代码来源:hgdaemon_server.php

示例4: commit_symbols

#!/usr/bin/env php
<?php 
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setSynopsis(<<<EOSYNOPSIS
**import_project_symbols.php** [__options__] __project_name__ < symbols

  Import project symbols (symbols are read from stdin).
EOSYNOPSIS
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'no-purge', 'help' => 'Do not clear all symbols for this project before ' . 'uploading new symbols. Useful for incremental updating.'), array('name' => 'ignore-errors', 'help' => 'If a line can\'t be parsed, ignore that line and ' . 'continue instead of exiting.'), array('name' => 'max-transaction', 'param' => 'num-syms', 'default' => '100000', 'help' => 'Maximum number of symbols that should ' . 'be part of a single transaction'), array('name' => 'more', 'wildcard' => true)));
$more = $args->getArg('more');
if (count($more) !== 1) {
    $args->printHelpAndExit();
}
$project_name = head($more);
$project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere('name = %s', $project_name);
if (!$project) {
    // TODO: Provide a less silly way to do this explicitly, or just do it right
    // here.
    echo "Project '{$project_name}' is unknown. Upload a diff to implicitly " . "create it.\n";
    exit(1);
}
echo "Parsing input from stdin...\n";
$input = file_get_contents('php://stdin');
$input = trim($input);
$input = explode("\n", $input);
function commit_symbols($syms, $project, $no_purge)
{
开发者ID:denghp,项目名称:phabricator,代码行数:31,代码来源:import_project_symbols.php

示例5: array

 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
$package_spec = array('javelin.pkg.js' => array('javelin-util', 'javelin-install', 'javelin-event', 'javelin-stratcom', 'javelin-behavior', 'javelin-request', 'javelin-vector', 'javelin-dom', 'javelin-json', 'javelin-uri'), 'typeahead.pkg.js' => array('javelin-typeahead', 'javelin-typeahead-normalizer', 'javelin-typeahead-source', 'javelin-typeahead-preloaded-source', 'javelin-typeahead-ondemand-source', 'javelin-tokenizer', 'javelin-behavior-aphront-basic-tokenizer'), 'core.pkg.js' => array('javelin-mask', 'javelin-workflow', 'javelin-behavior-workflow', 'javelin-behavior-aphront-form-disable-on-submit', 'phabricator-keyboard-shortcut-manager', 'phabricator-keyboard-shortcut', 'javelin-behavior-phabricator-keyboard-shortcuts', 'javelin-behavior-refresh-csrf', 'javelin-behavior-phabricator-watch-anchor', 'javelin-behavior-phabricator-autofocus', 'phabricator-paste-file-upload', 'phabricator-menu-item', 'phabricator-dropdown-menu', 'javelin-behavior-phabricator-oncopy', 'phabricator-tooltip', 'javelin-behavior-phabricator-tooltips', 'phabricator-prefab'), 'core.pkg.css' => array('phabricator-core-css', 'phabricator-core-buttons-css', 'phabricator-standard-page-view', 'aphront-dialog-view-css', 'aphront-form-view-css', 'aphront-panel-view-css', 'aphront-side-nav-view-css', 'aphront-table-view-css', 'aphront-crumbs-view-css', 'aphront-tokenizer-control-css', 'aphront-typeahead-control-css', 'aphront-list-filter-view-css', 'phabricator-directory-css', 'phabricator-jump-nav', 'phabricator-app-buttons-css', 'phabricator-remarkup-css', 'syntax-highlighting-css', 'aphront-pager-view-css', 'phabricator-transaction-view-css', 'aphront-tooltip-css', 'aphront-headsup-view-css', 'phabricator-flag-css', 'aphront-error-view-css'), 'differential.pkg.css' => array('differential-core-view-css', 'differential-changeset-view-css', 'differential-results-table-css', 'differential-revision-history-css', 'differential-table-of-contents-css', 'differential-revision-comment-css', 'differential-revision-add-comment-css', 'differential-revision-comment-list-css', 'phabricator-object-selector-css', 'aphront-headsup-action-list-view-css', 'phabricator-content-source-view-css', 'differential-local-commits-view-css', 'inline-comment-summary-css'), 'differential.pkg.js' => array('phabricator-drag-and-drop-file-upload', 'phabricator-shaped-request', 'javelin-behavior-differential-feedback-preview', 'javelin-behavior-differential-edit-inline-comments', 'javelin-behavior-differential-populate', 'javelin-behavior-differential-show-more', 'javelin-behavior-differential-diff-radios', 'javelin-behavior-differential-accept-with-errors', 'javelin-behavior-differential-comment-jump', 'javelin-behavior-differential-add-reviewers-and-ccs', 'javelin-behavior-differential-keyboard-navigation', 'javelin-behavior-aphront-drag-and-drop', 'javelin-behavior-aphront-drag-and-drop-textarea', 'javelin-behavior-phabricator-object-selector', 'javelin-behavior-repository-crossreference', 'differential-inline-comment-editor', 'javelin-behavior-differential-dropdown-menus', 'javelin-behavior-buoyant'), 'diffusion.pkg.css' => array('diffusion-commit-view-css', 'diffusion-icons-css'), 'diffusion.pkg.js' => array('javelin-behavior-diffusion-pull-lastmodified', 'javelin-behavior-diffusion-commit-graph', 'javelin-behavior-audit-preview'), 'maniphest.pkg.css' => array('maniphest-task-summary-css', 'maniphest-transaction-detail-css', 'aphront-attached-file-view-css', 'phabricator-project-tag-css'), 'maniphest.pkg.js' => array('javelin-behavior-maniphest-batch-selector', 'javelin-behavior-maniphest-transaction-controls', 'javelin-behavior-maniphest-transaction-preview', 'javelin-behavior-maniphest-transaction-expand', 'javelin-behavior-maniphest-subpriority-editor'));
require_once dirname(__FILE__) . '/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('map static resources');
$args->setSynopsis("**celerity_mapper.php** [--output __path__] [--with-custom] <webroot>");
$args->parse(array(array('name' => 'output', 'param' => 'path', 'default' => '../src/__celerity_resource_map__.php', 'help' => "Set the path for resource map. It is usually useful for " . "'celerity.resource-path' configuration."), array('name' => 'with-custom', 'help' => 'Include resources in <webroot>/rsrc/custom/.'), array('name' => 'webroot', 'wildcard' => true)));
$root = $args->getArg('webroot');
if (count($root) != 1 || !is_dir(reset($root))) {
    $args->printHelpAndExit();
}
$root = Filesystem::resolvePath(reset($root));
$celerity_path = Filesystem::resolvePath($args->getArg('output'), $root);
$with_custom = $args->getArg('with-custom');
$resource_hash = PhabricatorEnv::getEnvConfig('celerity.resource-hash');
$runtime_map = array();
echo "Finding raw static resources...\n";
$finder = id(new FileFinder($root))->withType('f')->withSuffix('png')->withSuffix('jpg')->withSuffix('gif')->withSuffix('swf')->withFollowSymlinks(true)->setGenerateChecksums(true);
if (!$with_custom) {
    $finder->excludePath('./rsrc/custom');
}
$raw_files = $finder->find();
开发者ID:nexeck,项目名称:phabricator,代码行数:31,代码来源:celerity_mapper.php

示例6: dirname

#!/usr/bin/env php
<?php 
require_once dirname(dirname(__FILE__)) . '/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'skip-hello', 'help' => 'Do not expect "capability" message when connecting. ' . 'The server must be configured not to send the message. ' . 'This deviates from the Mercurial protocol, but slightly ' . 'improves performance.'), array('name' => 'repository', 'wildcard' => true)));
$repo = $args->getArg('repository');
if (count($repo) !== 1) {
    throw new Exception('Specify exactly one working copy!');
}
$repo = head($repo);
$client = new ArcanistHgProxyClient($repo);
$client->setSkipHello($args->getArg('skip-hello'));
$t_start = microtime(true);
$result = $client->executeCommand(array('log', '--template', '{node}', '--rev', 2));
$t_end = microtime(true);
var_dump($result);
echo "\nExecuted in " . (int) (1000000 * ($t_end - $t_start)) . "us.\n";
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:18,代码来源:hgdaemon_client.php

示例7: dirname

#!/usr/bin/env php
<?php 
require_once dirname(__FILE__) . '/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('test context-free grammars'));
$args->setSynopsis(<<<EOHELP
**lipsum.php** __class__
    Generate output from a named context-free grammar.
EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'class', 'wildcard' => true)));
$class = $args->getArg('class');
if (count($class) !== 1) {
    $args->printHelpAndExit();
}
$class = reset($class);
$symbols = id(new PhutilClassMapQuery())->setAncestorClass('PhutilContextFreeGrammar')->execute();
$symbols = ipull($symbols, 'name', 'name');
if (empty($symbols[$class])) {
    $available = implode(', ', array_keys($symbols));
    throw new PhutilArgumentUsageException(pht("Class '%s' is not a defined, concrete subclass of %s. " . "Available classes are: %s", $class, 'PhutilContextFreeGrammar', $available));
}
$object = newv($class, array());
echo $object->generate() . "\n";
开发者ID:barcelonascience,项目名称:libphutil,代码行数:25,代码来源:lipsum.php

示例8: id

#!/usr/bin/env php
<?php 
require_once dirname(__FILE__) . '/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('test syntax highlighters'));
$args->setSynopsis(<<<EOHELP
**highlight.php** [__options__]
    Syntax highlight a corpus read from stdin.
EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'language', 'param' => 'language', 'help' => pht('Choose the highlight language.'))));
$language = $args->getArg('language');
$corpus = file_get_contents('php://stdin');
echo id(new PhutilDefaultSyntaxHighlighterEngine())->setConfig('pygments.enabled', true)->highlightSource($language, $corpus);
开发者ID:pritambaral,项目名称:libphutil,代码行数:15,代码来源:highlight.php

示例9: pht

        Dependencies on builtins and symbols marked '@phutil-external-symbol'
        in docblocks are omitted without __--all__.

        Symbols are reported in JSON on stdout.

        This script is used internally by libphutil/arcanist to build maps of
        library symbols.

        It would be nice to eventually implement this as a C++ xhpast binary,
        as it's relatively stable and performance is currently awful
        (500ms+ for moderately large files).

EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'all', 'help' => pht('Report all symbols, including built-ins and declared externals.')), array('name' => 'ugly', 'help' => pht('Do not prettify JSON output.')), array('name' => 'path', 'wildcard' => true, 'help' => pht('PHP Source file to analyze.'))));
$paths = $args->getArg('path');
if (count($paths) !== 1) {
    throw new Exception(pht('Specify exactly one path!'));
}
$path = Filesystem::resolvePath(head($paths));
$show_all = $args->getArg('all');
$source_code = Filesystem::readFile($path);
try {
    $tree = XHPASTTree::newFromData($source_code);
} catch (XHPASTSyntaxErrorException $ex) {
    $result = array('error' => $ex->getMessage(), 'line' => $ex->getErrorLine(), 'file' => $path);
    $json = new PhutilJSON();
    echo $json->encodeFormatted($result);
    exit(0);
}
开发者ID:endlessm,项目名称:libphutil,代码行数:31,代码来源:phutil_symbols.php

示例10: dirname

#!/usr/bin/env php
<?php 
require_once dirname(__FILE__) . '/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'attach', 'param' => 'file', 'help' => pht('Attach a file to the request.')), array('name' => 'url', 'wildcard' => true)));
$uri = $args->getArg('url');
if (count($uri) !== 1) {
    throw new PhutilArgumentUsageException('Specify exactly one URL to retrieve.');
}
$uri = head($uri);
$method = 'GET';
$data = '';
$timeout = 30;
$future = id(new HTTPSFuture($uri, $data))->setMethod($method)->setTimeout($timeout);
$attach_file = $args->getArg('attach');
if ($attach_file !== null) {
    $future->attachFileData('file', Filesystem::readFile($attach_file), basename($attach_file), Filesystem::getMimeType($attach_file));
}
print_r($future->resolve());
开发者ID:lsubra,项目名称:libphutil,代码行数:20,代码来源:http.php

示例11: foreach

// NOTE: This script is very oldschool and takes the environment as an argument.
// Some day, we could take a shot at cleaning this up.
if ($argc > 1) {
    foreach (array_slice($argv, 1) as $arg) {
        if (!preg_match('/^-/', $arg)) {
            $_SERVER['PHABRICATOR_ENV'] = $arg;
            break;
        }
    }
}
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
require_once $root . '/externals/mimemailparser/MimeMailParser.class.php';
$args = new PhutilArgumentParser($argv);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'process-duplicates', 'help' => pht("Process this message, even if it's a duplicate of another message. " . "This is mostly useful when debugging issues with mail routing.")), array('name' => 'env', 'wildcard' => true)));
$parser = new MimeMailParser();
$parser->setText(file_get_contents('php://stdin'));
$text_body = $parser->getMessageBody('text');
$text_body_headers = $parser->getMessageBodyHeaders('text');
$content_type = idx($text_body_headers, 'content-type');
if (!phutil_is_utf8($text_body) && (preg_match('/charset="(.*?)"/', $content_type, $matches) || preg_match('/charset=(\\S+)/', $content_type, $matches))) {
    $text_body = phutil_utf8_convert($text_body, 'UTF-8', $matches[1]);
}
$headers = $parser->getHeaders();
$headers['subject'] = iconv_mime_decode($headers['subject'], 0, 'UTF-8');
$headers['from'] = iconv_mime_decode($headers['from'], 0, 'UTF-8');
if ($args->getArg('process-duplicates')) {
    $headers['message-id'] = Filesystem::readRandomCharacters(64);
}
$received = new PhabricatorMetaMTAReceivedMail();
开发者ID:pugong,项目名称:phabricator,代码行数:31,代码来源:mail_handler.php

示例12: run

 /**
  * @task pull
  */
 public function run()
 {
     $argv = $this->getArgv();
     array_unshift($argv, __CLASS__);
     $args = new PhutilArgumentParser($argv);
     $args->parse(array(array('name' => 'no-discovery', 'help' => 'Pull only, without discovering commits.'), array('name' => 'not', 'param' => 'repository', 'repeat' => true, 'help' => 'Do not pull __repository__.'), array('name' => 'repositories', 'wildcard' => true, 'help' => 'Pull specific __repositories__ instead of all.')));
     $no_discovery = $args->getArg('no-discovery');
     $repo_names = $args->getArg('repositories');
     $exclude_names = $args->getArg('not');
     // Each repository has an individual pull frequency; after we pull it,
     // wait that long to pull it again. When we start up, try to pull everything
     // serially.
     $retry_after = array();
     $min_sleep = 15;
     while (true) {
         $repositories = $this->loadRepositories($repo_names);
         if ($exclude_names) {
             $exclude = $this->loadRepositories($exclude_names);
             $repositories = array_diff_key($repositories, $exclude);
         }
         // Shuffle the repositories, then re-key the array since shuffle()
         // discards keys. This is mostly for startup, we'll use soft priorities
         // later.
         shuffle($repositories);
         $repositories = mpull($repositories, null, 'getID');
         // If any repositories were deleted, remove them from the retry timer map
         // so we don't end up with a retry timer that never gets updated and
         // causes us to sleep for the minimum amount of time.
         $retry_after = array_select_keys($retry_after, array_keys($repositories));
         // Assign soft priorities to repositories based on how frequently they
         // should pull again.
         asort($retry_after);
         $repositories = array_select_keys($repositories, array_keys($retry_after)) + $repositories;
         foreach ($repositories as $id => $repository) {
             $after = idx($retry_after, $id, 0);
             if ($after > time()) {
                 continue;
             }
             $tracked = $repository->isTracked();
             if (!$tracked) {
                 continue;
             }
             try {
                 $callsign = $repository->getCallsign();
                 $this->log("Updating repository '{$callsign}'.");
                 $this->pullRepository($repository);
                 if (!$no_discovery) {
                     // TODO: It would be nice to discover only if we pulled something,
                     // but this isn't totally trivial.
                     $lock_name = get_class($this) . ':' . $callsign;
                     $lock = PhabricatorGlobalLock::newLock($lock_name);
                     $lock->lock();
                     try {
                         $this->discoverRepository($repository);
                     } catch (Exception $ex) {
                         $lock->unlock();
                         throw $ex;
                     }
                     $lock->unlock();
                 }
                 $sleep_for = $repository->getDetail('pull-frequency', $min_sleep);
                 $retry_after[$id] = time() + $sleep_for;
             } catch (PhutilLockException $ex) {
                 $retry_after[$id] = time() + $min_sleep;
                 $this->log("Failed to acquire lock.");
             } catch (Exception $ex) {
                 $retry_after[$id] = time() + $min_sleep;
                 phlog($ex);
             }
             $this->stillWorking();
         }
         if ($retry_after) {
             $sleep_until = max(min($retry_after), time() + $min_sleep);
         } else {
             $sleep_until = time() + $min_sleep;
         }
         $this->sleep($sleep_until - time());
     }
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:82,代码来源:PhabricatorRepositoryPullLocalDaemon.php

示例13: dirname

#!/usr/bin/env php
<?php 
require_once dirname(__FILE__) . '/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('edit directory fixtures'));
$args->setSynopsis(<<<EOHELP
**directory_fixture.php** __file__ --create
  Create a new directory fixture.

**directory_fixture.php** __file__
  Edit an existing directory fixture.

EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'create', 'help' => pht('Create a new fixture.')), array('name' => 'read-only', 'help' => pht('Do not save changes made to the fixture.')), array('name' => 'files', 'wildcard' => true)));
$is_create = $args->getArg('create');
$is_read_only = $args->getArg('read-only');
$console = PhutilConsole::getConsole();
$files = $args->getArg('files');
if (count($files) !== 1) {
    throw new PhutilArgumentUsageException(pht('Specify exactly one file to create or edit.'));
}
$file = head($files);
if ($is_create) {
    if (Filesystem::pathExists($file)) {
        throw new PhutilArgumentUsageException(pht('File "%s" already exists, so you can not %s it.', $file, '--create'));
    }
    $fixture = PhutilDirectoryFixture::newEmptyFixture();
} else {
    if (!Filesystem::pathExists($file)) {
开发者ID:SphinxGraph,项目名称:libphutil,代码行数:31,代码来源:directory_fixture.php

示例14: dirname

 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setSynopsis(<<<EOSYNOPSIS
**import_project_symbols.php** [__options__] __project_name__ < symbols

  Import project symbols (symbols are read from stdin).
EOSYNOPSIS
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'no-purge', 'help' => 'Do not clear all symbols for this project before ' . 'uploading new symbols. Useful for incremental updating.'), array('name' => 'more', 'wildcard' => true)));
$more = $args->getArg('more');
if (count($more) !== 1) {
    $args->printHelpAndExit();
}
$project_name = head($more);
$project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere('name = %s', $project_name);
if (!$project) {
    // TODO: Provide a less silly way to do this explicitly, or just do it right
    // here.
    echo "Project '{$project_name}' is unknown. Upload a diff to implicitly " . "create it.\n";
    exit(1);
}
echo "Parsing input from stdin...\n";
$input = file_get_contents('php://stdin');
$input = trim($input);
开发者ID:neoxen,项目名称:phabricator,代码行数:31,代码来源:import_project_symbols.php

示例15: dirname

#!/usr/bin/env php
<?php 
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setSynopsis(<<<EOSYNOPSIS
**clear_repository_symbols.php** [__options__] __repository__

  Clear repository symbols.
EOSYNOPSIS
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'repository', 'wildcard' => true)));
$identifiers = $args->getArg('repository');
if (count($identifiers) !== 1) {
    $args->printHelpAndExit();
}
$identifier = head($identifiers);
$repository = id(new PhabricatorRepositoryQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIdentifiers($identifiers)->executeOne();
if (!$repository) {
    echo tsprintf("%s\n", pht('Repository "%s" does not exist.', $identifier));
    exit(1);
}
$input = file_get_contents('php://stdin');
$normalized = array();
foreach (explode("\n", trim($input)) as $path) {
    // Emulate the behavior of the symbol generation scripts.
    $normalized[] = '/' . ltrim($path, './');
}
$paths = PhabricatorRepositoryCommitChangeParserWorker::lookupOrCreatePaths($normalized);
$symbol = new PhabricatorRepositorySymbol();
开发者ID:rchicoli,项目名称:phabricator,代码行数:31,代码来源:clear_repository_symbols.php


注:本文中的PhutilArgumentParser::parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。