本文整理汇总了PHP中PhutilArgumentParser::getUnconsumedArgumentVector方法的典型用法代码示例。如果您正苦于以下问题:PHP PhutilArgumentParser::getUnconsumedArgumentVector方法的具体用法?PHP PhutilArgumentParser::getUnconsumedArgumentVector怎么用?PHP PhutilArgumentParser::getUnconsumedArgumentVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhutilArgumentParser
的用法示例。
在下文中一共展示了PhutilArgumentParser::getUnconsumedArgumentVector方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPartialParse
public function testPartialParse()
{
$specs = array(array('name' => 'flag'));
$args = new PhutilArgumentParser(array('bin', 'a', '--flag', '--', 'b'));
$args->parsePartial($specs);
$this->assertEqual(array('a', '--', 'b'), $args->getUnconsumedArgumentVector());
}
示例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'));
}
示例3: dirname
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'.");
}
} else {
if ($help) {
示例4: execute
public function execute(PhutilArgumentParser $args)
{
$unconsumed = $args->getUnconsumedArgumentVector();
echo implode(' ', $unconsumed) . "\n";
return 0;
}
示例5: __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'));
}
示例6: Exception
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()) {
$err = 0;
示例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.