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


PHP PhutilArgumentParser::parsePartial方法代码示例

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


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

示例1: array

**storage** upgrade
Initialize or upgrade Phabricator storage.

**storage** upgrade --user __root__ --password __hunter2__
Use administrative credentials for schema changes.
EOHELP
);
$args->parseStandardArguments();
$conf = PhabricatorEnv::newObjectFromConfig('mysql.configuration-provider', array($dao = null, 'w'));
$default_user = $conf->getUser();
$default_host = $conf->getHost();
$default_port = $conf->getPort();
$default_namespace = PhabricatorLiskDAO::getDefaultStorageNamespace();
try {
    $args->parsePartial(array(array('name' => 'force', 'short' => 'f', 'help' => pht('Do not prompt before performing dangerous operations.')), array('name' => 'user', 'short' => 'u', 'param' => 'username', 'default' => $default_user, 'help' => pht("Connect with __username__ instead of the configured default ('%s').", $default_user)), array('name' => 'password', 'short' => 'p', 'param' => 'password', 'help' => pht('Use __password__ instead of the configured default.')), array('name' => 'namespace', 'param' => 'name', 'default' => $default_namespace, 'help' => pht("Use namespace __namespace__ instead of the configured " . "default ('%s'). This is an advanced feature used by unit tests; " . "you should not normally use this flag.", $default_namespace)), array('name' => 'dryrun', 'help' => pht('Do not actually change anything, just show what would be changed.')), array('name' => 'disable-utf8mb4', 'help' => pht('Disable utf8mb4, even if the database supports it. This is an ' . 'advanced feature used for testing changes to Phabricator; you ' . 'should not normally use this flag.'))));
} catch (PhutilArgumentUsageException $ex) {
    $args->printUsageException($ex);
    exit(77);
}
// First, test that the Phabricator configuration is set up correctly. After
// we know this works we'll test any administrative credentials specifically.
$test_api = new PhabricatorStorageManagementAPI();
$test_api->setUser($default_user);
$test_api->setHost($default_host);
$test_api->setPort($default_port);
$test_api->setPassword($conf->getPassword());
$test_api->setNamespace($args->getArg('namespace'));
try {
    queryfx($test_api->getConn(null), 'SELECT 1');
} catch (AphrontQueryException $ex) {
开发者ID:JohnnyEstilles,项目名称:phabricator,代码行数:30,代码来源:manage_storage.php

示例2: __construct

    public function __construct(array $argv)
    {
        PhutilServiceProfiler::getInstance()->enableDiscardMode();
        $original_argv = $argv;
        $args = new PhutilArgumentParser($argv);
        $args->setTagline('daemon overseer');
        $args->setSynopsis(<<<EOHELP
**launch_daemon.php** [__options__] __daemon__
    Launch and oversee an instance of __daemon__.
EOHELP
);
        $args->parseStandardArguments();
        $args->parsePartial(array(array('name' => 'trace-memory', 'help' => 'Enable debug memory tracing.'), array('name' => 'log', 'param' => 'file', 'help' => 'Send output to __file__.'), array('name' => 'daemonize', 'help' => 'Run in the background.'), array('name' => 'phd', 'param' => 'dir', 'help' => 'Write PID information to __dir__.'), array('name' => 'verbose', 'help' => 'Enable verbose activity logging.'), array('name' => 'load-phutil-library', 'param' => 'library', 'repeat' => true, 'help' => 'Load __library__.')));
        $argv = array();
        $more = $args->getUnconsumedArgumentVector();
        $this->daemon = array_shift($more);
        if (!$this->daemon) {
            $args->printHelpAndExit();
        }
        if ($args->getArg('trace')) {
            $this->traceMode = true;
            $argv[] = '--trace';
        }
        if ($args->getArg('trace-memory')) {
            $this->traceMode = true;
            $this->traceMemory = true;
            $argv[] = '--trace-memory';
        }
        if ($args->getArg('load-phutil-library')) {
            foreach ($args->getArg('load-phutil-library') as $library) {
                $argv[] = '--load-phutil-library=' . $library;
            }
        }
        $log = $args->getArg('log');
        if ($log) {
            ini_set('error_log', $log);
            $argv[] = '--log=' . $log;
        }
        $verbose = $args->getArg('verbose');
        if ($verbose) {
            $this->verbose = true;
            $argv[] = '--verbose';
        }
        $this->daemonize = $args->getArg('daemonize');
        $this->phddir = $args->getArg('phd');
        $this->argv = $argv;
        $this->moreArgs = coalesce($more, array());
        error_log("Bringing daemon '{$this->daemon}' online...");
        if (self::$instance) {
            throw new Exception('You may not instantiate more than one Overseer per process.');
        }
        self::$instance = $this;
        if ($this->daemonize) {
            // We need to get rid of these or the daemon will hang when we TERM it
            // waiting for something to read the buffers. TODO: Learn how unix works.
            fclose(STDOUT);
            fclose(STDERR);
            ob_start();
            $pid = pcntl_fork();
            if ($pid === -1) {
                throw new Exception('Unable to fork!');
            } else {
                if ($pid) {
                    exit(0);
                }
            }
        }
        if ($this->phddir) {
            $desc = array('name' => $this->daemon, 'argv' => $this->moreArgs, 'pid' => getmypid(), 'start' => time());
            Filesystem::writeFile($this->phddir . '/daemon.' . getmypid(), json_encode($desc));
        }
        $this->daemonID = $this->generateDaemonID();
        $this->dispatchEvent(self::EVENT_DID_LAUNCH, array('argv' => array_slice($original_argv, 1), 'explicitArgv' => $this->moreArgs));
        declare (ticks=1);
        pcntl_signal(SIGUSR1, array($this, 'didReceiveKeepaliveSignal'));
        pcntl_signal(SIGUSR2, array($this, 'didReceiveNotifySignal'));
        pcntl_signal(SIGINT, array($this, 'didReceiveGracefulSignal'));
        pcntl_signal(SIGTERM, array($this, 'didReceiveTerminalSignal'));
    }
开发者ID:lsubra,项目名称:libphutil,代码行数:79,代码来源:PhutilDaemonOverseer.php

示例3: __construct

    public function __construct(array $argv)
    {
        PhutilServiceProfiler::getInstance()->enableDiscardMode();
        $original_argv = $argv;
        $args = new PhutilArgumentParser($argv);
        $args->setTagline('daemon overseer');
        $args->setSynopsis(<<<EOHELP
**launch_daemon.php** [__options__] __daemon__
    Launch and oversee an instance of __daemon__.
EOHELP
);
        $args->parsePartial(array(array('name' => 'trace', 'help' => 'Enable debug tracing.'), array('name' => 'trace-memory', 'help' => 'Enable debug memory tracing.'), array('name' => 'log', 'param' => 'file', 'help' => 'Send output to __file__.'), array('name' => 'daemonize', 'help' => 'Run in the background.'), array('name' => 'phd', 'param' => 'dir', 'help' => 'Write PID information to __dir__.'), array('name' => 'conduit-uri', 'param' => 'uri', 'help' => 'Send logs to Conduit on __uri__.'), array('name' => 'verbose', 'help' => 'Enable verbose activity logging.')));
        $argv = $args->getUnconsumedArgumentVector();
        $this->daemon = array_shift($argv);
        if (!$this->daemon) {
            $args->printHelpAndExit();
        }
        if ($args->getArg('trace')) {
            $this->traceMode = true;
            array_unshift($argv, '--trace');
        }
        if ($args->getArg('trace-memory')) {
            $this->traceMode = true;
            $this->traceMemory = true;
            array_unshift($argv, '--trace-memory');
        }
        $log = $args->getArg('log');
        if ($log) {
            ini_set('error_log', $log);
            array_unshift($argv, '--log=' . $log);
        }
        $verbose = $args->getArg('verbose');
        if ($verbose) {
            $this->verbose = true;
            array_unshift($argv, '--verbose');
        }
        $this->daemonize = $args->getArg('daemonize');
        $this->phddir = $args->getArg('phd');
        $this->conduitURI = $args->getArg('conduit-uri');
        $this->argv = $argv;
        error_log("Bringing daemon '{$this->daemon}' online...");
        if (self::$instance) {
            throw new Exception("You may not instantiate more than one Overseer per process.");
        }
        self::$instance = $this;
        if ($this->daemonize) {
            // We need to get rid of these or the daemon will hang when we TERM it
            // waiting for something to read the buffers. TODO: Learn how unix works.
            fclose(STDOUT);
            fclose(STDERR);
            ob_start();
            $pid = pcntl_fork();
            if ($pid === -1) {
                throw new Exception("Unable to fork!");
            } else {
                if ($pid) {
                    exit(0);
                }
            }
        }
        if ($this->phddir) {
            $desc = array('name' => $this->daemon, 'pid' => getmypid(), 'start' => time());
            Filesystem::writeFile($this->phddir . '/daemon.' . getmypid(), json_encode($desc));
        }
        if ($this->conduitURI) {
            $this->conduit = new ConduitClient($this->conduitURI);
            $this->daemonLogID = $this->conduit->callMethodSynchronous('daemon.launched', array('daemon' => $this->daemon, 'host' => php_uname('n'), 'pid' => getmypid(), 'argv' => json_encode(array_slice($original_argv, 1))));
        }
        declare (ticks=1);
        pcntl_signal(SIGUSR1, array($this, 'didReceiveKeepaliveSignal'));
        pcntl_signal(SIGINT, array($this, 'didReceiveTerminalSignal'));
        pcntl_signal(SIGTERM, array($this, 'didReceiveTerminalSignal'));
    }
开发者ID:rwray,项目名称:libphutil,代码行数:73,代码来源:PhutilDaemonOverseer.php

示例4: dirname

#!/usr/bin/env php
<?php 
sanity_check_environment();
require_once dirname(__FILE__) . '/__init_script__.php';
ini_set('memory_limit', -1);
$original_argv = $argv;
$base_args = new PhutilArgumentParser($argv);
$base_args->parseStandardArguments();
$base_args->parsePartial(array(array('name' => 'load-phutil-library', 'param' => 'path', 'help' => 'Load a libphutil library.', 'repeat' => true), array('name' => 'skip-arcconfig'), array('name' => 'arcrc-file', 'param' => 'filename'), array('name' => 'conduit-uri', 'param' => 'uri', 'help' => 'Connect to Phabricator install specified by __uri__.'), array('name' => 'conduit-version', 'param' => 'version', 'help' => '(Developers) Mock client version in protocol handshake.'), array('name' => 'conduit-timeout', 'param' => 'timeout', 'help' => 'Set Conduit timeout (in seconds).'), array('name' => 'config', 'param' => 'key=value', 'repeat' => true, 'help' => 'Specify a runtime configuration value. This will take precedence ' . 'over static values, and only affect the current arcanist invocation.')));
$config_trace_mode = $base_args->getArg('trace');
$force_conduit = $base_args->getArg('conduit-uri');
$force_conduit_version = $base_args->getArg('conduit-version');
$conduit_timeout = $base_args->getArg('conduit-timeout');
$skip_arcconfig = $base_args->getArg('skip-arcconfig');
$custom_arcrc = $base_args->getArg('arcrc-file');
$load = $base_args->getArg('load-phutil-library');
$help = $base_args->getArg('help');
$args = array_values($base_args->getUnconsumedArgumentVector());
$working_directory = getcwd();
$console = PhutilConsole::getConsole();
$config = null;
$workflow = null;
try {
    $console->writeLog("libphutil loaded from '%s'.\n", phutil_get_library_root('phutil'));
    $console->writeLog("arcanist loaded from '%s'.\n", phutil_get_library_root('arcanist'));
    if (!$args) {
        if ($help) {
            $args = array('help');
        } else {
            throw new ArcanistUsageException("No command provided. Try 'arc help'.");
        }
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:31,代码来源:arcanist.php

示例5: Exception

require_once $root . '/scripts/__init_script__.php';
if ($argc < 2) {
    throw new Exception(pht('usage: commit-hook <repository>'));
}
$engine = new DiffusionCommitHookEngine();
$repository = id(new PhabricatorRepositoryQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIdentifiers(array($argv[1]))->needProjectPHIDs(true)->executeOne();
if (!$repository) {
    throw new Exception(pht('No such repository "%s"!', $argv[1]));
}
if (!$repository->isHosted()) {
    // This should be redundant, but double check just in case.
    throw new Exception(pht('Repository "%s" is not hosted!', $argv[1]));
}
$engine->setRepository($repository);
$args = new PhutilArgumentParser($argv);
$args->parsePartial(array(array('name' => 'hook-mode', 'param' => 'mode', 'help' => pht('Hook execution mode.'))));
$argv = array_merge(array($argv[0]), $args->getUnconsumedArgumentVector());
// Figure out which user is writing the commit.
$hook_mode = $args->getArg('hook-mode');
if ($hook_mode !== null) {
    $known_modes = array('svn-revprop' => true);
    if (empty($known_modes[$hook_mode])) {
        throw new Exception(pht('Invalid Hook Mode: This hook was invoked in "%s" mode, but this ' . 'is not a recognized hook mode. Valid modes are: %s.', $hook_mode, implode(', ', array_keys($known_modes))));
    }
}
$is_svnrevprop = $hook_mode == 'svn-revprop';
if ($is_svnrevprop) {
    // For now, we let these through if the repository allows dangerous changes
    // and prevent them if it doesn't. See T11208 for discussion.
    $revprop_key = $argv[5];
    if ($repository->shouldAllowDangerousChanges()) {
开发者ID:rchicoli,项目名称:phabricator,代码行数:31,代码来源:commit_hook.php

示例6: array

Manage Phabricator database storage and schema versioning.

**storage** upgrade
Initialize or upgrade Phabricator storage.

**storage** upgrade --user __root__ --password __hunter2__
Use administrative credentials for schema changes.
EOHELP
);
$args->parseStandardArguments();
$conf = PhabricatorEnv::newObjectFromConfig('mysql.configuration-provider', array($dao = null, 'w'));
$default_user = $conf->getUser();
$default_host = $conf->getHost();
$default_namespace = PhabricatorLiskDAO::getDefaultStorageNamespace();
try {
    $args->parsePartial(array(array('name' => 'force', 'short' => 'f', 'help' => 'Do not prompt before performing dangerous operations.'), array('name' => 'user', 'short' => 'u', 'param' => 'username', 'default' => $default_user, 'help' => "Connect with __username__ instead of the configured " . "default ('{$default_user}')."), array('name' => 'password', 'short' => 'p', 'param' => 'password', 'help' => 'Use __password__ instead of the configured default.'), array('name' => 'namespace', 'param' => 'name', 'default' => $default_namespace, 'help' => "Use namespace __namespace__ instead of the configured " . "default ('{$default_namespace}'). This is an advanced " . "feature used by unit tests; you should not normally " . "use this flag."), array('name' => 'dryrun', 'help' => 'Do not actually change anything, just show what would be ' . 'changed.')));
} catch (PhutilArgumentUsageException $ex) {
    $args->printUsageException($ex);
    exit(77);
}
if ($args->getArg('password') === null) {
    // This is already a PhutilOpaqueEnvelope.
    $password = $conf->getPassword();
} else {
    // Put this in a PhutilOpaqueEnvelope.
    $password = new PhutilOpaqueEnvelope($args->getArg('password'));
}
$api = new PhabricatorStorageManagementAPI();
$api->setUser($args->getArg('user'));
$api->setHost($default_host);
$api->setPassword($password);
开发者ID:rudimk,项目名称:phabricator,代码行数:31,代码来源:manage_storage.php

示例7: ssh_connect_signal

#!/usr/bin/env php
<?php 
// This is a wrapper script for Git, Mercurial, and Subversion. It primarily
// serves to inject "-o StrictHostKeyChecking=no" into the SSH arguments.
// In some cases, Subversion sends us SIGTERM. If we don't catch the signal and
// react to it, we won't run object destructors by default and thus won't clean
// up temporary files. Declare ticks so we can install a signal handler.
declare (ticks=1);
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
// Contrary to the documentation, Git may pass a "-p" flag. If it does, respect
// it and move it before the "--" argument.
$args = new PhutilArgumentParser($argv);
$args->parsePartial(array(array('name' => 'port', 'short' => 'p', 'param' => pht('port'), 'help' => pht('Port number to connect to.'))));
$unconsumed_argv = $args->getUnconsumedArgumentVector();
if (function_exists('pcntl_signal')) {
    pcntl_signal(SIGTERM, 'ssh_connect_signal');
}
function ssh_connect_signal($signo)
{
    // This is just letting destructors fire. In particular, we want to clean
    // up any temporary files we wrote. See T10547.
    exit(128 + $signo);
}
$pattern = array();
$arguments = array();
$pattern[] = 'ssh';
$pattern[] = '-o';
$pattern[] = 'StrictHostKeyChecking=no';
// This prevents "known host" failures, and covers for issues where HOME is set
// to something unusual.
开发者ID:rchicoli,项目名称:phabricator,代码行数:31,代码来源:ssh-connect.php

示例8: testStdinValidParameter

 public function testStdinValidParameter()
 {
     $specs = array(array('name' => 'file', 'param' => 'file'));
     $args = new PhutilArgumentParser(array('bin', '-', '--file', '-'));
     $args->parsePartial($specs);
     $this->assertEqual('-', $args->getArg('file'));
 }
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:7,代码来源:PhutilArgumentParserTestCase.php

示例9: dirname

 *
 *   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.
 */
sanity_check_environment();
require_once dirname(__FILE__) . '/__init_script__.php';
ini_set('memory_limit', -1);
$original_argv = $argv;
$args = new PhutilArgumentParser($argv);
$args->parseStandardArguments();
$args->parsePartial(array(array('name' => 'load-phutil-library', 'param' => 'path', 'help' => 'Load a libphutil library.', 'repeat' => true), array('name' => 'conduit-uri', 'param' => 'uri', 'help' => 'Connect to Phabricator install specified by __uri__.'), array('name' => 'conduit-version', 'param' => 'version', 'help' => '(Developers) Mock client version in protocol handshake.'), array('name' => 'conduit-timeout', 'param' => 'timeout', 'help' => 'Set Conduit timeout (in seconds).')));
$config_trace_mode = $args->getArg('trace');
$force_conduit = $args->getArg('conduit-uri');
$force_conduit_version = $args->getArg('conduit-version');
$conduit_timeout = $args->getArg('conduit-timeout');
$load = $args->getArg('load-phutil-library');
$argv = $args->getUnconsumedArgumentVector();
$args = array_values($argv);
$working_directory = getcwd();
$console = PhutilConsole::getConsole();
try {
    if ($config_trace_mode) {
        $phutil_location = phutil_get_library_root('phutil');
        $arcanist_location = phutil_get_library_root('arcanist');
        $console->writeErr("libphutil loaded from '{$phutil_location}'.\n");
        $console->writeErr("arcanist loaded from '{$arcanist_location}'.\n");
开发者ID:rafikk,项目名称:arcanist,代码行数:31,代码来源:arcanist.php


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