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


PHP parseArgs函数代码示例

本文整理汇总了PHP中parseArgs函数的典型用法代码示例。如果您正苦于以下问题:PHP parseArgs函数的具体用法?PHP parseArgs怎么用?PHP parseArgs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: genCast

function genCast($func, $indent)
{
    global $current_server;
    $funcname = $func->name;
    $async = @$func->async;
    $args_set = parseArgs(@$func->args);
    // decode args
    $arg_count = count($args_set);
    if ($arg_count) {
        $argsType = getArgsType($funcname);
        echo "{$indent}{$argsType} _args;\n";
        echo "{$indent}const bool _fOk = cerl::getMailBody(_ar, _args);\n\n";
        echo "{$indent}CERL_ASSERT(_fOk && \"{$current_server}::_handle_cast - {$funcname}\");\n";
        echo "{$indent}if (_fOk)\n";
    } else {
        echo "{$indent}NS_CERL_IO::check_vt_null(_ar);\n";
    }
    $indent2 = $arg_count ? $indent . "\t" : $indent;
    echo "{$indent2}{$funcname}(caller";
    if ($arg_count == 1) {
        echo ", _args";
    } else {
        foreach ($args_set as $var => $tp) {
            echo ", _args.{$var}";
        }
    }
    echo ");\n";
}
开发者ID:greatbody,项目名称:cerl,代码行数:28,代码来源:gen_stub.php

示例2: main

/**
 * Main function
 *
 * @param string[] $argv Program parameters
 *
 * @return void
 * @throws Exception
 */
function main($argv)
{
    $params = parseArgs($argv);
    applyConfigOverrides($params);
    if (empty($params['source']) || !is_string($params['source'])) {
        echo <<<EOT
Usage: {$argv['0']} --source=... [...]

Parameters:

--source            Repository id ('*' for all, separate multiple sources
                    with commas)
--exclude           Repository id's to exclude when using '*' for source
                    (separate multiple sources with commas)
--from              Override harvesting start date
--until             Override harvesting end date
--all               Harvest from beginning (overrides --from)
--verbose           Enable verbose output
--override          Override initial resumption token
                    (e.g. to resume failed connection)
--reharvest[=date]  This is a full reharvest, delete all records that were not
                    received during the harvesting (or were modified before [date]).
                    Implies --all.
--config.section.name=value
                    Set configuration directive to given value overriding any
                    setting in recordmanager.ini
--lockfile=file     Use a lock file to avoid executing the command multiple times in
                    parallel (useful when running from crontab)


EOT;
        exit(1);
    }
    $lockfile = isset($params['lockfile']) ? $params['lockfile'] : '';
    $lockhandle = false;
    try {
        if (($lockhandle = acquireLock($lockfile)) === false) {
            die;
        }
        $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false);
        $from = isset($params['from']) ? $params['from'] : null;
        if (isset($params['all']) || isset($params['reharvest'])) {
            $from = '-';
        }
        foreach (explode(',', $params['source']) as $source) {
            $manager->harvest($source, $from, isset($params['until']) ? $params['until'] : null, isset($params['override']) ? urldecode($params['override']) : '', isset($params['exclude']) ? $params['exclude'] : null, isset($params['reharvest']) ? $params['reharvest'] : '');
        }
    } catch (Exception $e) {
        releaseLock($lockhandle);
        throw $e;
    }
    releaseLock($lockhandle);
}
开发者ID:grharry,项目名称:RecordManager,代码行数:61,代码来源:harvest.php

示例3: main

/**
 * Main function 
 * 
 * @param string[] $argv Program parameters
 * 
 * @return void
 */
function main($argv)
{
    $params = parseArgs($argv);
    if (!isset($params['input']) || !isset($params['output'])) {
        echo "Usage: splitlog --input=... --output=...\n\n";
        echo "Parameters:\n\n";
        echo "--input             A harvest debug log file\n";
        echo "--output            A file mask for output (e.g. output%d.xml)\n";
        echo "--verbose           Enable verbose output\n\n";
        exit(1);
    }
    $fh = fopen($params['input'], 'r');
    $out = null;
    $count = 0;
    $inResponse = false;
    $emptyLines = 2;
    while ($line = fgets($fh)) {
        $line = chop($line);
        if (!$line) {
            ++$emptyLines;
            continue;
        }
        //echo "Empty: $emptyLines, $inResponse, line: '$line'\n";
        if ($emptyLines >= 2 && $line == 'Request:') {
            fgets($fh);
            fgets($fh);
            $inResponse = true;
            $emptyLines = 0;
            ++$count;
            $filename = sprintf($params['output'], $count);
            echo "Creating file '{$filename}'\n";
            if ($out) {
                fclose($out);
            }
            $out = fopen($filename, 'w');
            if ($out === false) {
                die("Could not open output file\n");
            }
            continue;
        }
        $emptyLines = 0;
        if ($inResponse) {
            fputs($out, $line . "\n");
        }
    }
    if ($out) {
        fclose($out);
    }
    echo "Done.\n";
}
开发者ID:grharry,项目名称:RecordManager,代码行数:57,代码来源:splitlog.php

示例4: main

/**
 * Main function
 *
 * @param string[] $argv Program parameters
 *
 * @return void
 */
function main($argv)
{
    $params = parseArgs($argv);
    applyConfigOverrides($params);
    if (empty($params['search'])) {
        echo <<<EOT
Usage: {$argv['0']} --search=...

Parameters:

--search=[regexp]   Search for a string in data sources and list the data source id's


EOT;
        exit(1);
    }
    $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false);
    if (!empty($params['search'])) {
        $manager->searchDataSources($params['search']);
    }
}
开发者ID:grharry,项目名称:RecordManager,代码行数:28,代码来源:datasources.php

示例5: main

/**
 * Main function
 *
 * @param string[] $argv Program parameters
 *
 * @return void
 * @throws Exception
 */
function main($argv)
{
    $params = parseArgs($argv);
    applyConfigOverrides($params);
    if (empty($params['file']) || empty($params['source'])) {
        echo <<<EOT
Usage: {$argv['0']} --file=... --source=... [...]

Parameters:

--file              The file or wildcard pattern of files of records
--source            Source ID
--verbose           Enable verbose output
--config.section.name=value
                   Set configuration directive to given value overriding any
                   setting in recordmanager.ini
--lockfile=file    Use a lock file to avoid executing the command multiple times in
                   parallel (useful when running from crontab)


EOT;
        exit(1);
    }
    $lockfile = isset($params['lockfile']) ? $params['lockfile'] : '';
    $lockhandle = false;
    try {
        if (($lockhandle = acquireLock($lockfile)) === false) {
            die;
        }
        $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false);
        $manager->loadFromFile($params['source'], $params['file']);
    } catch (Exception $e) {
        releaseLock($lockhandle);
        throw $e;
    }
    releaseLock($lockhandle);
}
开发者ID:grharry,项目名称:RecordManager,代码行数:45,代码来源:import.php

示例6: main

/**
 * Main function
 *
 * @param string[] $argv Program parameters
 *
 * @return void
 */
function main($argv)
{
    $params = parseArgs($argv);
    applyConfigOverrides($params);
    if (empty($params['file'])) {
        echo <<<EOT
Usage: {$argv['0']} --file=... [...]

Parameters:

--file=...          The file for records
--deleted=...       The file for deleted record IDs
--from=...          From date where to start the export
--verbose           Enable verbose output
--quiet             Quiet, no output apart from the data
--skip=...          Skip x records to export only a "representative" subset
--source=...        Export only the given source(s)
                    (separate multiple sources with commas)
--single=...        Export single record with the given id
--xpath=...         Export only records matching the XPath expression
--config.section.name=...
                    Set configuration directive to given value overriding
                    any setting in recordmanager.ini
--sortdedup         Sort export file by dedup id
--dedupid=...       deduped = Add dedup id's to records that have duplicates
                    always  = Always add dedup id's to the records
                    Otherwise dedup id's are not added to the records


EOT;
        exit(1);
    }
    $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false);
    $manager->quiet = isset($params['quiet']) ? $params['quiet'] : false;
    $manager->exportRecords($params['file'], isset($params['deleted']) ? $params['deleted'] : '', isset($params['from']) ? $params['from'] : '', isset($params['skip']) ? $params['skip'] : 0, isset($params['source']) ? $params['source'] : '', isset($params['single']) ? $params['single'] : '', isset($params['xpath']) ? $params['xpath'] : '', isset($params['sortdedup']) ? $params['sortdedup'] : false, isset($params['dedupid']) ? $params['dedupid'] : '');
}
开发者ID:grharry,项目名称:RecordManager,代码行数:43,代码来源:export.php

示例7: processArgType

function processArgType($func, $indent)
{
    $name = $func->name;
    $args_set = parseArgs(@$func->args);
    $i = count($args_set);
    if ($i == 0) {
        return;
    } else {
        if ($i == 1) {
            foreach ($args_set as $var => $type) {
                $typename = mapType($type, "");
                $argsTyName = getArgsType($name);
                echo "\n{$indent}typedef {$typename} {$argsTyName};\n";
            }
        } else {
            echo "\n{$indent}typedef struct {\n";
            foreach ($args_set as $var => $type) {
                $typename = mapType($type, "");
                echo "{$indent}\t{$typename} {$var};\n";
            }
            $argsTyName = getArgsType($name);
            echo "{$indent}} {$argsTyName};\n";
        }
    }
}
开发者ID:greatbody,项目名称:cerl,代码行数:25,代码来源:functions.php

示例8: trim

             case 1:
                 /* cut off function as second part of input string and keep rest for further parsing */
                 $function = trim(substr($input_string, 0, $pos));
                 $input_string = trim(strchr($input_string, ' ')) . ' ';
                 break;
             case 2:
                 /* take the rest as parameter(s) to the function stripped off previously */
                 $parameters = trim($input_string);
                 break 2;
         }
     } else {
         break;
     }
     $i++;
 }
 if (!parseArgs($parameters, $parameter_array)) {
     cacti_log("WARNING: Script Server count not parse '{$parameters}' for {$function}", false, 'PHPSVR');
     fputs(STDOUT, "U\n");
     continue;
 }
 if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_DEBUG) {
     cacti_log("DEBUG: PID[{$pid}] CTR[{$ctr}] INC: '" . basename($include_file) . "' FUNC: '" . $function . "' PARMS: '" . $parameters . "'", false, 'PHPSVR');
 }
 /* validate the existance of the function, and include if applicable */
 if (!function_exists($function)) {
     if (file_exists($include_file)) {
         /* quirk in php on Windows, believe it or not.... */
         /* path must be lower case */
         if ($config['cacti_server_os'] == 'win32') {
             $include_file = strtolower($include_file);
         }
开发者ID:andrei1489,项目名称:cacti,代码行数:31,代码来源:script_server.php

示例9: genCtor

function genCtor($class_name, $ctor, $indent)
{
    echo "\n";
    echo "{$indent}";
    if (!count($ctor) || !@$ctor->args) {
        echo "explicit ";
    }
    //echo "${class_name}(cerl::Fiber self";
    echo "{$class_name}(";
    if (count($ctor)) {
        $args = parseArgs(@$ctor->args);
        $i = 0;
        foreach ($args as $var => $tp) {
            if ($i == 0) {
                $typename = mapType($tp, "&");
                echo "const {$typename} {$var}";
            } else {
                $typename = mapType($tp, "&");
                echo ", const {$typename} {$var}";
            }
            $i = $i + 1;
        }
    }
    //echo ")\n${indent}\t: self(_me)\n";
    echo ")\n";
    echo "{$indent}{\n{$indent}}\n";
}
开发者ID:greatbody,项目名称:cerl,代码行数:27,代码来源:gen_impl.php

示例10: structureAddon

 /**
  * add extra's, buttons, drop downs, etc. 
  *
  * @author Paul Whitehead
  * @return object
  */
 private function structureAddon($type = 'prepend')
 {
     if (!is_array($this->input[$type]) or empty($this->input[$type])) {
         return $this;
     }
     //combine our arugments
     $addon = parseArgs($this->input[$type], $this->addon_defaults);
     //check if we want a drop down box
     //if options have not been provided
     if (!is_array($this->input[$type]['options']) or empty($this->input[$type]['options'])) {
         //check for the need to do anything
         if (is_array($this->input[$type]) and !empty($this->input[$type])) {
             $this->form_build[] = '<' . $addon['type'] . ' class="add-on">' . $addon['value'] . '</' . $addon['type'] . '>';
         }
         //if we have options
     } else {
         $this->form_build[] = '<div class="btn-group">';
         $this->form_build[] = '<button class="btn dropdown-toggle" data-toggle="dropdown">' . $addon['value'];
         $this->form_build[] = '<span class="caret"></span></button>';
         $this->form_build[] = '<ul class="dropdown-menu">';
         foreach ($this->input[$type]['options'] as $key => $value) {
             //check if a divider is requested
             if ($key == 'divider' and $value === true) {
                 $this->form_build[] = '<li class="divider"></li>';
                 continue;
             }
             //check is we just have a simple string or value
             if (!is_array($value)) {
                 $this->form_build[] = $key;
                 continue;
             }
             $this->form_build[] = '<li><a ' . $this->attrKeyValue($value, array('icon')) . '>' . $value['title'] . '</a></li>';
             continue;
         }
         $this->form_build[] = '</ul>';
         $this->form_build[] = '</div>';
     }
     return $this;
 }
开发者ID:prwhitehead,项目名称:meagr,代码行数:45,代码来源:form.php

示例11: ini_set

#!/usr/bin/env php
<?php 
require __DIR__ . '/../lib/bootstrap.php';
ini_set('xdebug.max_nesting_level', 3000);
// Disable XDebug var_dump() output truncation
ini_set('xdebug.var_display_max_children', -1);
ini_set('xdebug.var_display_max_data', -1);
ini_set('xdebug.var_display_max_depth', -1);
list($operations, $files, $attributes) = parseArgs($argv);
/* Dump nodes by default */
if (empty($operations)) {
    $operations[] = 'dump';
}
if (empty($files)) {
    showHelp("Must specify at least one file.");
}
$lexer = new PhpParser\Lexer\Emulative(array('usedAttributes' => array('startLine', 'endLine', 'startFilePos', 'endFilePos')));
$parser = new PhpParser\Parser($lexer);
$dumper = new PhpParser\NodeDumper();
$prettyPrinter = new PhpParser\PrettyPrinter\Standard();
$serializer = new PhpParser\Serializer\XML();
$traverser = new PhpParser\NodeTraverser();
$traverser->addVisitor(new PhpParser\NodeVisitor\NameResolver());
foreach ($files as $file) {
    if (strpos($file, '<?php') === 0) {
        $code = $file;
        echo "====> Code {$code}\n";
    } else {
        if (!file_exists($file)) {
            die("File {$file} does not exist.\n");
        }
开发者ID:a53ali,项目名称:CakePhP,代码行数:31,代码来源:php-parse.php

示例12: list

#!/usr/bin/env php
<?php 
require_once __DIR__ . '/helper.php';
use Dropbox as dbx;
/* @var dbx\Client $client */
/* @var string $sourcePath */
/* @var string $dropboxPath */
list($client, $sourcePath, $dropboxPath) = parseArgs("upload-file", $argv, array(array("source-path", "A path to a local file or a URL of a resource."), array("dropbox-path", "The path (on Dropbox) to save the file to.")));
$pathError = dbx\Path::findErrorNonRoot($dropboxPath);
if ($pathError !== null) {
    fwrite(STDERR, "Invalid <dropbox-path>: {$pathError}\n");
    die;
}
$size = null;
if (\stream_is_local($sourcePath)) {
    $size = \filesize($sourcePath);
}
$fp = fopen($sourcePath, "rb");
$metadata = $client->uploadFile($dropboxPath, dbx\WriteMode::add(), $fp, $size);
fclose($fp);
print_r($metadata);
开发者ID:andrefedalto,项目名称:htv,代码行数:21,代码来源:upload-file.php

示例13: define

//define("DBF_HOST", "localhost");
//define("DBF_USER", "ipplan");
//define("DBF_NAME", "ipplan");
//define("DBF_PASSWORD", "ipplan99");
// define the nmap command for normal scan
define("NMAP_CMD", "-sP -PE -q -n -oG");
// define the nmap command for scan with dns lookup
define("NMAP_CMDH", "-sP -PE -q -R -v -oG");
require_once "../adodb/adodb.inc.php";
require_once "../config.php";
$timestamp = FALSE;
$hostnames = FALSE;
$audit = FALSE;
// Set Defaults
// $options["h"]=TRUE;
parseArgs($argv, $options);
// options will be $options["FLAG"] (if not argument is given like -h the
// $options["h"] will be set to bolean true
if (isset($options["a"]) && $options["a"] == TRUE) {
    $audit = TRUE;
}
if (isset($options["time"]) && $options["time"] == TRUE) {
    $timestamp = TRUE;
}
if (isset($options["hostnames"]) && $options["hostnames"] == TRUE) {
    $hostnames = TRUE;
}
if (!isset($options["q"])) {
    if (!empty($_REQUEST)) {
        echo "<br>Mmm, this is a command line utility not to be executed via a web browser! Try the -q option\n";
        exit(1);
开发者ID:hetznerZA,项目名称:ipplan,代码行数:31,代码来源:ipplan-poller.php

示例14: main

/**
 * Main function
 *
 * @param string[] $argv Program parameters
 *
 * @return void
 * @throws Exception
 */
function main($argv)
{
    $params = parseArgs($argv);
    applyConfigOverrides($params);
    if (empty($params['func']) || !is_string($params['func'])) {
        echo <<<EOT
Usage: {$argv['0']} --func=... [...]

Parameters:

--func             renormalize|deduplicate|updatesolr|dump|dumpsolr|markdeleted
                   |deletesource|deletesolr|optimizesolr|count|checkdedup|comparesolr
                   |purgedeleted|markdedup
--source           Source ID to process (separate multiple sources with commas)
--all              Process all records regardless of their state (deduplicate,
                   markdedup)
                   or date (updatesolr)
--from             Override the date from which to run the update (updatesolr)
--single           Process only the given record id (deduplicate, updatesolr, dump)
--nocommit         Don't ask Solr to commit the changes (updatesolr)
--field            Field to analyze (count)
--force            Force deletesource to proceed even if deduplication is enabled for
                   the source
--verbose          Enable verbose output for debugging
--config.section.name=value
                   Set configuration directive to given value overriding any setting
                   in recordmanager.ini
--lockfile=file    Use a lock file to avoid executing the command multiple times in
                   parallel (useful when running from crontab)
--comparelog       Record comparison output file. N.B. The file will be overwritten
                   (comparesolr)
--dumpprefix       File name prefix to use when dumping records (dumpsolr). Default
                   is "dumpsolr".
--mapped           If set, use values only after any mapping files are processed when
                   counting records (count)
--daystokeep=days  How many last days to keep when purging deleted records
                   (purgedeleted)


EOT;
        exit(1);
    }
    $lockfile = isset($params['lockfile']) ? $params['lockfile'] : '';
    $lockhandle = false;
    try {
        if (($lockhandle = acquireLock($lockfile)) === false) {
            die;
        }
        $manager = new RecordManager(true, isset($params['verbose']) ? $params['verbose'] : false);
        $sources = isset($params['source']) ? $params['source'] : '';
        $single = isset($params['single']) ? $params['single'] : '';
        $noCommit = isset($params['nocommit']) ? $params['nocommit'] : false;
        // Solr update, compare and dump can handle multiple sources at once
        if ($params['func'] == 'updatesolr' || $params['func'] == 'dumpsolr') {
            $date = isset($params['all']) ? '' : (isset($params['from']) ? $params['from'] : null);
            $dumpPrefix = $params['func'] == 'dumpsolr' ? isset($params['dumpprefix']) ? $params['dumpprefix'] : 'dumpsolr' : '';
            $manager->updateSolrIndex($date, $sources, $single, $noCommit, '', $dumpPrefix);
        } elseif ($params['func'] == 'comparesolr') {
            $date = isset($params['all']) ? '' : (isset($params['from']) ? $params['from'] : null);
            $manager->updateSolrIndex($date, $sources, $single, $noCommit, isset($params['comparelog']) ? $params['comparelog'] : '-');
        } else {
            foreach (explode(',', $sources) as $source) {
                switch ($params['func']) {
                    case 'renormalize':
                        $manager->renormalize($source, $single);
                        break;
                    case 'deduplicate':
                    case 'markdedup':
                        $manager->deduplicate($source, isset($params['all']) ? true : false, $single, $params['func'] == 'markdedup');
                        break;
                    case 'dump':
                        $manager->dumpRecord($single);
                        break;
                    case 'deletesource':
                        $manager->deleteRecords($source, isset($params['force']) ? $params['force'] : false);
                        break;
                    case 'markdeleted':
                        $manager->markDeleted($source);
                        break;
                    case 'deletesolr':
                        $manager->deleteSolrRecords($source);
                        break;
                    case 'optimizesolr':
                        $manager->optimizeSolr();
                        break;
                    case 'count':
                        $manager->countValues($source, isset($params['field']) ? $params['field'] : null, isset($params['mapped']) ? $params['mapped'] : false);
                        break;
                    case 'checkdedup':
                        $manager->checkDedupRecords();
                        break;
                    case 'purgedeleted':
//.........这里部分代码省略.........
开发者ID:grharry,项目名称:RecordManager,代码行数:101,代码来源:manage.php

示例15: list

#!/usr/bin/env php
<?php 
require_once __DIR__ . '/helper.php';
use Dropbox as dbx;
/* @var dbx\Client $client */
/* @var string $dropboxPath */
list($client, $dropboxPath) = parseArgs("link", $argv, array(array("dropbox-path", "The path (on Dropbox) to create a link for.")));
$pathError = dbx\Path::findError($dropboxPath);
if ($pathError !== null) {
    fwrite(STDERR, "Invalid <dropbox-path>: {$pathError}\n");
    die;
}
$link = $client->createShareableLink($dropboxPath);
print $link . "\n";
开发者ID:andrefedalto,项目名称:htv,代码行数:14,代码来源:link.php


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