本文整理匯總了PHP中showUsage函數的典型用法代碼示例。如果您正苦於以下問題:PHP showUsage函數的具體用法?PHP showUsage怎麽用?PHP showUsage使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了showUsage函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
public function __construct($fileName)
{
$this->handle = fopen($fileName, 'r');
if (!$this->handle) {
throw new Exception("Can't open '{$fileName}'");
}
$this->stack[-1] = array('', 0, 0, 0, 0);
$this->stack[0] = array('', 0, 0, 0, 0);
$this->stackFunctions = array();
$header1 = fgets($this->handle);
$header2 = fgets($this->handle);
if (!preg_match('@Version: 2.*@', $header1) || !preg_match('@File format: [2-4]@', $header2)) {
echo "\nThis file is not an Xdebug trace file made with format option '1' and version 2 to 4.\n";
showUsage();
}
}
示例2: array
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
* @ingroup Maintenance
* @author Rob Church <robchur@gmail.com>
* @author Mij <mij@bitchx.it>
*/
$optionsWithArgs = array('extensions', 'comment', 'comment-file', 'comment-ext', 'user', 'license', 'sleep', 'limit', 'from', 'source-wiki-url');
require_once dirname(__FILE__) . '/commandLine.inc';
require_once dirname(__FILE__) . '/importImages.inc';
$processed = $added = $ignored = $skipped = $overwritten = $failed = 0;
echo "Import Images\n\n";
# Need a path
if (count($args) == 0) {
showUsage();
}
$dir = $args[0];
# Check Protection
if (isset($options['protect']) && isset($options['unprotect'])) {
die("Cannot specify both protect and unprotect. Only 1 is allowed.\n");
}
if (isset($options['protect']) && $options['protect'] == 1) {
die("You must specify a protection option.\n");
}
# Prepare the list of allowed extensions
global $wgFileExtensions;
$extensions = isset($options['extensions']) ? explode(',', strtolower($options['extensions'])) : $wgFileExtensions;
# Search the path provided for candidates for import
$files = findFiles($dir, $extensions);
# Initialise the user for this operation
示例3: fail
if (isset($aCMDResult['create-website'])) {
$bDidSomething = true;
$sTargetDir = $aCMDResult['create-website'];
if (!is_dir($sTargetDir)) {
fail('please specify a directory to setup');
}
@symlink(CONST_BasePath . '/website/details.php', $sTargetDir . '/details.php');
@symlink(CONST_BasePath . '/website/reverse.php', $sTargetDir . '/reverse.php');
@symlink(CONST_BasePath . '/website/search.php', $sTargetDir . '/search.php');
@symlink(CONST_BasePath . '/website/search.php', $sTargetDir . '/index.php');
@symlink(CONST_BasePath . '/website/images', $sTargetDir . '/images');
@symlink(CONST_BasePath . '/website/js', $sTargetDir . '/js');
echo "Symlinks created\n";
}
if (!$bDidSomething) {
showUsage($aCMDOptions, true);
}
function pgsqlRunScriptFile($sFilename)
{
if (!file_exists($sFilename)) {
fail('unable to find ' . $sFilename);
}
// Convert database DSN to psql paramaters
$aDSNInfo = DB::parseDSN(CONST_Database_DSN);
$sCMD = 'psql -f ' . $sFilename . ' ' . $aDSNInfo['database'];
$aDescriptors = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('file', '/dev/null', 'a'));
$ahPipes = null;
$hProcess = proc_open($sCMD, $aDescriptors, $ahPipes);
if (!is_resource($hProcess)) {
fail('unable to start pgsql');
}
示例4: dirname
#!/usr/bin/php -Cq
<?php
require_once dirname(dirname(__FILE__)) . '/lib/init-cmd.php';
ini_set('memory_limit', '800M');
$aCMDOptions = array("Import / update / index osm data", array('help', 'h', 0, 1, 0, 0, false, 'Show Help'), array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'), array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'), array('max-load', '', 0, 1, 1, 1, 'float', 'Maximum load average - indexing is paused if this is exceeded'), array('max-blocking', '', 0, 1, 1, 1, 'int', 'Maximum blocking processes - indexing is aborted / paused if this is exceeded'), array('import-osmosis', '', 0, 1, 0, 0, 'bool', 'Import using osmosis'), array('import-osmosis-all', '', 0, 1, 0, 0, 'bool', 'Import using osmosis forever'), array('no-npi', '', 0, 1, 0, 0, 'bool', 'Do not write npi index files'), array('no-index', '', 0, 1, 0, 0, 'bool', 'Do not index the new data'), array('import-npi-all', '', 0, 1, 0, 0, 'bool', 'Import npi pre-indexed files'), array('import-hourly', '', 0, 1, 0, 0, 'bool', 'Import hourly diffs'), array('import-daily', '', 0, 1, 0, 0, 'bool', 'Import daily diffs'), array('import-all', '', 0, 1, 0, 0, 'bool', 'Import all available files'), array('import-file', '', 0, 1, 1, 1, 'realpath', 'Re-import data from an OSM file'), array('import-diff', '', 0, 1, 1, 1, 'realpath', 'Import a diff (osc) file from local file system'), array('osm2pgsql-cache', '', 0, 1, 1, 1, 'int', 'Cache size used by osm2pgsql'), array('import-node', '', 0, 1, 1, 1, 'int', 'Re-import node'), array('import-way', '', 0, 1, 1, 1, 'int', 'Re-import way'), array('import-relation', '', 0, 1, 1, 1, 'int', 'Re-import relation'), array('import-from-main-api', '', 0, 1, 0, 0, 'bool', 'Use OSM API instead of Overpass to download objects'), array('index', '', 0, 1, 0, 0, 'bool', 'Index'), array('index-rank', '', 0, 1, 1, 1, 'int', 'Rank to start indexing from'), array('index-instances', '', 0, 1, 1, 1, 'int', 'Number of indexing instances (threads)'), array('index-estrate', '', 0, 1, 1, 1, 'int', 'Estimated indexed items per second (def:30)'), array('deduplicate', '', 0, 1, 0, 0, 'bool', 'Deduplicate tokens'));
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
if ($aResult['import-hourly'] + $aResult['import-daily'] + isset($aResult['import-diff']) > 1) {
showUsage($aCMDOptions, true, 'Select either import of hourly or daily');
}
if (!isset($aResult['index-instances'])) {
$aResult['index-instances'] = 1;
}
if (!isset($aResult['index-rank'])) {
$aResult['index-rank'] = 0;
}
/*
// Lock to prevent multiple copies running
if (exec('/bin/ps uww | grep '.basename(__FILE__).' | grep -v /dev/null | grep -v grep -c', $aOutput2, $iResult) > 1)
{
echo "Copy already running\n";
exit;
}
if (!isset($aResult['max-load'])) $aResult['max-load'] = 1.9;
if (!isset($aResult['max-blocking'])) $aResult['max-blocking'] = 3;
if (getBlockingProcesses() > $aResult['max-blocking'])
{
echo "Too many blocking processes for import\n";
exit;
}
*/
// Assume osm2pgsql is in the folder above
示例5: getCmdOpt
function getCmdOpt($aArg, $aSpec, &$aResult, $bExitOnError = false, $bExitOnUnknown = false)
{
$aQuick = array();
$aCounts = array();
foreach ($aSpec as $aLine) {
if (is_array($aLine)) {
if ($aLine[0]) {
$aQuick['--' . $aLine[0]] = $aLine;
}
if ($aLine[1]) {
$aQuick['-' . $aLine[1]] = $aLine;
}
$aCounts[$aLine[0]] = 0;
}
}
$aResult = array();
$bUnknown = false;
$iSize = sizeof($aArg);
for ($i = 1; $i < $iSize; $i++) {
if (isset($aQuick[$aArg[$i]])) {
$aLine = $aQuick[$aArg[$i]];
$aCounts[$aLine[0]]++;
$xVal = null;
if ($aLine[4] == $aLine[5]) {
if ($aLine[4]) {
$xVal = array();
for ($n = $aLine[4]; $i < $iSize && $n; $n--) {
$i++;
if ($i >= $iSize || $aArg[$i][0] == '-') {
showUsage($aSpec, $bExitOnError, 'Paramater of \'' . $aLine[0] . '\' is missing');
}
switch ($aLine[6]) {
case 'realpath':
$xVal[] = realpath($aArg[$i]);
break;
case 'realdir':
$sPath = realpath(dirname($aArg[$i]));
if ($sPath) {
$xVal[] = $sPath . '/' . basename($aArg[$i]);
} else {
$xVal[] = $sPath;
}
break;
case 'bool':
$xVal[] = (bool) $aArg[$i];
break;
case 'int':
$xVal[] = (int) $aArg[$i];
break;
default:
$xVal[] = $aArg[$i];
break;
}
}
if ($aLine[4] == 1) {
$xVal = $xVal[0];
}
} else {
$xVal = true;
}
} else {
return factory::throwError('Variable numbers of params not yet supported');
}
if ($aLine[3] > 1) {
if (!array_key_exists($aLine[0], $aResult)) {
$aResult[$aLine[0]] = array();
}
$aResult[$aLine[0]][] = $xVal;
} else {
$aResult[$aLine[0]] = $xVal;
}
} else {
$bUnknown = $aArg[$i];
}
}
if (array_key_exists('help', $aResult)) {
showUsage($aSpec);
}
if ($bUnknown && $bExitOnUnknown) {
showUsage($aSpec, $bExitOnError, 'Unknown option \'' . $bUnknown . '\'');
}
foreach ($aSpec as $aLine) {
if (is_array($aLine)) {
if ($aCounts[$aLine[0]] < $aLine[2]) {
showUsage($aSpec, $bExitOnError, 'Option \'' . $aLine[0] . '\' is missing');
}
if ($aCounts[$aLine[0]] > $aLine[3]) {
showUsage($aSpec, $bExitOnError, 'Option \'' . $aLine[0] . '\' is pressent too many times');
}
switch ($aLine[6]) {
case 'bool':
if (!array_key_exists($aLine[0], $aResult)) {
$aResult[$aLine[0]] = false;
}
break;
}
}
}
return $bUnknown;
}
示例6: error_reporting
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$version = '0.0.1';
require 'lib/colors.php';
require 'lib/functions.php';
$opts = array('nobad' => false, 'nogood' => false, 'noinfo' => false, 'nocolor' => false, 'forcemem' => false, 'forceswap' => false, 'host' => false, 'socket' => false, 'port' => false, 'user' => false, 'pass' => false, 'skipsize' => false, 'checkversion' => false, 'help' => false);
// Load our options from either $_REQUEST, or from command line
loadOpts();
if ($opts['help'] !== false) {
exit(showUsage());
}
示例7: configuration
Options:
-h --help This help
-c --config path to MongoTripodConfig configuration (required)
-s --storename Store to create views for (required)
-d --spec Only create for specified search document specs
-i --id Resource ID to regenerate search documents for
-a --async Generate table rows via queue
-q --queue Queue name to place jobs on (defaults to configured TRIPOD_APPLY_QUEUE value)
--stat-loader Path to script to initialize a Stat object. Note, it *must* return an iTripodStat object!
END;
echo $help;
}
if (empty($options) || isset($options['h']) || isset($options['help']) || !isset($options['c']) && !isset($options['config']) || !isset($options['s']) && !isset($options['storename'])) {
showUsage($argv[0]);
exit;
}
$configLocation = isset($options['c']) ? $options['c'] : $options['config'];
require_once dirname(dirname(dirname(__FILE__))) . '/src/tripod.inc.php';
/**
* @param string|null $id
* @param string|null $specId
* @param string|null $storeName
* @param \Tripod\iTripodStat|null $stat
* @param string|null $queue
*/
function generateSearchDocuments($id, $specId, $storeName, $stat = null, $queue = null)
{
$spec = \Tripod\Mongo\Config::getInstance()->getSearchDocumentSpecification($storeName, $specId);
if (array_key_exists("from", $spec)) {