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


PHP Console_Getopt::getopt2方法代码示例

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


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

示例1: array

 /**
  * constructor
  */
 function __construct()
 {
     //	$include_path = "packages/" . get_include_path( );
     //	set_include_path( $include_path );
     require_once 'Console/Getopt.php';
     $shortOptions = "s:u:p:k:";
     $longOptions = array('site=', 'user', 'pass');
     $getopt = new Console_Getopt();
     $args = $getopt->readPHPArgv();
     array_shift($args);
     list($valid, $this->args) = $getopt->getopt2($args, $shortOptions, $longOptions);
     $vars = array('user' => 'u', 'pass' => 'p', 'key' => 'k', 'site' => 's');
     foreach ($vars as $var => $short) {
         ${$var} = NULL;
         foreach ($valid as $v) {
             if ($v[0] == $short || $v[0] == "--{$var}") {
                 ${$var} = $v[1];
                 break;
             }
         }
         if (!${$var}) {
             die("\nUsage: \$ php5 " . $_SERVER['PHP_SELF'] . " -k key -u user -p password -s yoursite.org\n");
         }
     }
     $this->site = $site;
     $this->key = $key;
     $this->setEnv();
     $this->authenticate($user, $pass);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:32,代码来源:cli.php

示例2: run

function run()
{
    session_start();
    require_once '../civicrm.config.php';
    require_once 'CRM/Core/Config.php';
    $config = CRM_Core_Config::singleton();
    require_once 'Console/Getopt.php';
    $shortOptions = "n:p:k:pre";
    $longOptions = array('name=', 'pass=', 'key=', 'prefix=');
    $getopt = new Console_Getopt();
    $args = $getopt->readPHPArgv();
    array_shift($args);
    list($valid, $dontCare) = $getopt->getopt2($args, $shortOptions, $longOptions);
    $vars = array('name' => 'n', 'pass' => 'p', 'key' => 'k', 'prefix' => 'pre');
    foreach ($vars as $var => $short) {
        ${$var} = NULL;
        foreach ($valid as $v) {
            if ($v[0] == $short || $v[0] == "--{$var}") {
                ${$var} = $v[1];
                break;
            }
        }
        if (!${$var}) {
            ${$var} = CRM_Utils_Array::value($var, $_REQUEST);
        }
        $_REQUEST[$var] = ${$var};
    }
    // this does not return on failure
    // require_once 'CRM/Utils/System.php';
    CRM_Utils_System::authenticateScript(TRUE, $name, $pass);
    //log the execution of script
    CRM_Core_Error::debug_log_message('NormalizePhone.php');
    // process all phones
    processPhones($config, $prefix);
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:35,代码来源:NormalizePhone.php

示例3: array

 /**
  * constructor
  */
 function __construct($authenticate = true)
 {
     //	$include_path = "packages/" . get_include_path( );
     //	set_include_path( $include_path );
     if (!$authenticate) {
         $this->setEnv();
         return;
     }
     require_once 'Console/Getopt.php';
     $shortOptions = "s:u:p:";
     $longOptions = array('site=', 'user', 'pass');
     $getopt = new Console_Getopt();
     $args = $getopt->readPHPArgv();
     array_shift($args);
     list($valid, $this->args) = $getopt->getopt2($args, $shortOptions, $longOptions);
     $vars = array('user' => 'u', 'pass' => 'p', 'site' => 's');
     foreach ($vars as $var => $short) {
         ${$var} = null;
         foreach ($valid as $v) {
             if ($v[0] == $short || $v[0] == "--{$var}") {
                 ${$var} = $v[1];
                 break;
             }
         }
         if (!${$var}) {
             $a = explode('/', $_SERVER["SCRIPT_NAME"]);
             $file = $a[count($a) - 1];
             die("\nUsage: \$cd /your/civicrm/root; \$php5 bin/" . $file . " -u user -p password -s yoursite.org (or default)\n");
         }
     }
     $this->site = $site;
     $this->setEnv();
     $this->authenticate($user, $pass);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:37,代码来源:cli.php

示例4: _parseArgs

 /**
  * returns the commandline arguments of a function
  *
  * @param    string  $argv           the commandline
  * @param    string  $short_options  the allowed option short-tags
  * @param    string  $long_options   the allowed option long-tags
  * @return   array   the given options and there values
  * @static
  * @access private
  */
 function _parseArgs($argv, $short_options, $long_options = null)
 {
     if (!is_array($argv) && $argv !== null) {
         $argv = preg_split('/\\s+/', $argv, -1, PREG_SPLIT_NO_EMPTY);
     }
     return Console_Getopt::getopt2($argv, $short_options);
 }
开发者ID:studyfordream,项目名称:Cato-CRUD-Generator,代码行数:17,代码来源:System.php

示例5: raiseError

 function raiseError($error)
 {
     $this->graph = new Image_GraphViz(true, array('fontname' => 'Verdana', 'fontsize' => 12.0, 'rankdir' => 'LR'));
     if (PEAR::isError($error)) {
         $error = $error->getMessage();
     }
     trigger_error($error, E_USER_WARNING);
     return Console_Getopt::getopt2($argv, $short_options);
 }
开发者ID:exakat,项目名称:exakat,代码行数:9,代码来源:PearUsage.01.php

示例6: get

 function get($path)
 {
     ini_set('memory_limit', '256M');
     // we need alot of memory
     set_time_limit(0);
     $argv = $_SERVER['argv'];
     array_shift($argv);
     array_shift($argv);
     $opts = explode(',', 'table==,where==,dump-dir==,debug=');
     require_once 'Console/Getopt.php';
     $go = Console_Getopt::getopt2($argv, '', $opts);
     if (is_object($go)) {
         die($go->toString());
     }
     foreach ($go[0] as $ar) {
         $args[substr($ar[0], 2)] = $ar[1];
     }
     $errs = array();
     foreach ($opts as $req) {
         if (substr($req, -2, 2) != '==') {
             // skip optional arguments
             continue;
         }
         if (empty($args[substr($req, 0, -2)])) {
             $errs[] = "--" . substr($req, 0, -2) . ' is required';
         }
     }
     if (!empty($errs)) {
         die(print_R($errs, true));
     }
     if (!empty($args['debug'])) {
         DB_DataObject::debugLevel($args['debug']);
     }
     $this->args = $args;
     $this->out = array();
     $this->discoverChildren($this->args['table'], $this->args['where'], true);
     //print_R($this->deletes);
     //print_r($this->dumps);
     //exit;
     $this->discover($this->args['table'], $this->args['where'], true);
     if (!file_exists($args['dump-dir'])) {
         mkdir($args['dump-dir'], 0777, true);
     }
     // create uid's
     // dump items..
     echo "GENERATED FILES:\n";
     // summary
     echo "    " . implode("\n    ", $this->out) . "\n";
     exit;
 }
开发者ID:roojs,项目名称:Pman.Admin,代码行数:50,代码来源:Export.php

示例7: _parseArgs

 /**
  * returns the commandline arguments of a function
  *
  * @param    string  $argv           the commandline
  * @param    string  $short_options  the allowed option short-tags
  * @param    string  $long_options   the allowed option long-tags
  * @return   array   the given options and there values
  * @static
  * @access private
  */
 static function _parseArgs($argv, $short_options, $long_options = null)
 {
     if (!is_array($argv) && $argv !== null) {
         // Find all items, quoted or otherwise
         preg_match_all("/(?:[\"'])(.*?)(?:['\"])|([^\\s]+)/", $argv, $av);
         $argv = $av[1];
         foreach ($av[2] as $k => $a) {
             if (empty($a)) {
                 continue;
             }
             $argv[$k] = trim($a);
         }
     }
     return Console_Getopt::getopt2($argv, $short_options, $long_options);
 }
开发者ID:roojs,项目名称:pear,代码行数:25,代码来源:System.php

示例8: array

function &get_commandline()
{
    $cg = new Console_Getopt();
    $args = $cg->readPHPArgv();
    array_shift($args);
    $shortOpts = 'h::v::';
    $longOpts = array('ini=', 'force==');
    $params = $cg->getopt2($args, $shortOpts, $longOpts);
    $new_params = array();
    foreach ($params[0] as $param) {
        $param[0] = str_replace('--', '', $param[0]);
        $new_params[$param[0]] = $param[1];
    }
    unset($params);
    return $new_params;
}
开发者ID:garv347,项目名称:swanhart-tools,代码行数:16,代码来源:setup_flexcdc.php

示例9: array

function &get_commandline()
{
    $cg = new Console_Getopt();
    $args = $cg->readPHPArgv();
    array_shift($args);
    $shortOpts = 'h::v::';
    $longOpts = array('ini=', 'help==', 'pid=', 'daemon==');
    $params = $cg->getopt2($args, $shortOpts, $longOpts);
    if (PEAR::isError($params)) {
        echo 'Error: ' . $params->getMessage() . "\n";
        exit(1);
    }
    $new_params = array();
    foreach ($params[0] as $param) {
        $param[0] = str_replace('--', '', $param[0]);
        $new_params[$param[0]] = $param[1];
    }
    unset($params);
    return $new_params;
}
开发者ID:garv347,项目名称:swanhart-tools,代码行数:20,代码来源:cleanup_history.php

示例10: run

function run()
{
    session_start();
    require_once '../civicrm.config.php';
    require_once 'CRM/Core/Config.php';
    $config =& CRM_Core_Config::singleton();
    require_once 'Console/Getopt.php';
    $shortOptions = "n:p:s:e:k:";
    $longOptions = array('name=', 'pass=', 'key=', 'start=', 'end=');
    $getopt = new Console_Getopt();
    $args = $getopt->readPHPArgv();
    array_shift($args);
    list($valid, $dontCare) = $getopt->getopt2($args, $shortOptions, $longOptions);
    $vars = array('start' => 's', 'end' => 'e', 'name' => 'n', 'pass' => 'p', 'key' => 'k');
    foreach ($vars as $var => $short) {
        ${$var} = null;
        foreach ($valid as $v) {
            if ($v[0] == $short || $v[0] == "--{$var}") {
                ${$var} = $v[1];
                break;
            }
        }
        if (!${$var}) {
            ${$var} = CRM_Utils_Array::value($var, $_REQUEST);
        }
        $_REQUEST[$var] = ${$var};
    }
    // this does not return on failure
    // require_once 'CRM/Utils/System.php';
    CRM_Utils_System::authenticateScript(true, $name, $pass);
    // check that we have a geocodeMethod
    if (empty($config->geocodeMethod)) {
        echo ts('Error: You need to set a mapping provider under Global Settings');
        exit;
    }
    $config->userFramework = 'Soap';
    $config->userFrameworkClass = 'CRM_Utils_System_Soap';
    $config->userHookClass = 'CRM_Utils_Hook_Soap';
    // we have an exclusive lock - run the mail queue
    processContacts($config, $start, $end);
}
开发者ID:ksecor,项目名称:civicrm,代码行数:41,代码来源:UpdateAddress.php

示例11: array

function &get_commandline($more_longopts = array())
{
    $cg = new Console_Getopt();
    $args = $cg->readPHPArgv();
    array_shift($args);
    $shortOpts = 'h::v::';
    $longOpts = array('user=', 'ini=', 'password=', 'host=', 'db=', 'port=', 'help==', 'verbose==', 'method=', 'gearman=', 'inlist=', 'between=', 'directory=', 'push_where', 'inlist_merge_threshold==', 'inlist_merge_size==', 'coord_engine==', 'schema=', 'batch');
    $longOpts = array_merge($longOpts, $more_longopts);
    @($params = $cg->getopt2($args, $shortOpts, $longOpts));
    if (@PEAR::isError($params)) {
        echo 'Error: ' . $params->getMessage() . "\n";
        exit(1);
    }
    $new_params = array();
    foreach ($params[0] as $param) {
        $param[0] = str_replace('--', '', $param[0]);
        $new_params[$param[0]] = $param[1];
    }
    unset($params);
    return $new_params;
}
开发者ID:garv347,项目名称:swanhart-tools,代码行数:21,代码来源:common.php

示例12: ini_set

/** include_pathの設定(このtest runnerがあるディレクトリを追加) */
ini_set('include_path', dirname(BASE) . PATH_SEPARATOR . ini_get('include_path'));
/** Ethna関連クラスのインクルード */
require_once 'Ethna/Ethna.php';
/** SimpleTestのインクルード */
require_once 'simpletest/unit_tester.php';
require_once 'simpletest/reporter.php';
require_once 'Ethna/test/TextDetailReporter.php';
require_once 'Ethna/test/Ethna_UnitTestBase.php';
/** テストケースがあるディレクトリ */
$test_dir = ETHNA_BASE . '/test';
$test =& new GroupTest('Ethna All tests');
// テストケースのファイルリストを取得
require_once 'Console/Getopt.php';
$args = Console_Getopt::readPHPArgv();
list($args, $opts) = Console_Getopt::getopt2($args, '', array());
array_shift($opts);
if (count($opts) > 0) {
    $file_list = $opts;
} else {
    $file_list = getFileList($test_dir);
}
// テストケースを登録
foreach ($file_list as $file) {
    $test->addTestFile($file);
}
// 結果をコマンドラインに出力
//$test->run(new TextReporter());
$test->run(new TextDetailReporter());
//{{{ getFileList
/**
开发者ID:hiroki-namekawa,项目名称:test-upr,代码行数:31,代码来源:ethna_run_test.php

示例13: array

 /**
  * easy getopt :)
  *
  * @param   array   $lopts  long options
  * @return  array   list($opts, $args)
  * @access  protected
  */
 function &_getopt($lopts = array())
 {
     // create opts
     // ex: $lopts = array('foo', 'bar=');
     $lopts = to_array($lopts);
     $sopts = '';
     $opt_def = array();
     foreach ($lopts as $lopt) {
         if ($lopt[strlen($lopt) - 2] === '=') {
             $opt_def[$lopt[0]] = substr($lopt, 0, strlen($lopt) - 2);
             $sopts .= $lopt[0] . '::';
         } else {
             if ($lopt[strlen($lopt) - 1] === '=') {
                 $opt_def[$lopt[0]] = substr($lopt, 0, strlen($lopt) - 1);
                 $sopts .= $lopt[0] . ':';
             } else {
                 $opt_def[$lopt[0]] = $lopt;
                 $sopts .= $lopt[0];
             }
         }
     }
     // do getopt
     // ex: $sopts = 'fb:';
     $opts_args = Console_Getopt::getopt2($this->arg_list, $sopts, $lopts);
     if (Ethna::isError($opts_args)) {
         return $opts_args;
     }
     // parse opts
     // ex: "-ff --bar=baz" gets
     //      $opts = array('foo' => array(true, true),
     //                    'bar' => array('baz'));
     $opts = array();
     foreach ($opts_args[0] as $opt) {
         $opt[0] = $opt[0][0] === '-' ? $opt_def[$opt[0][2]] : $opt_def[$opt[0][0]];
         $opt[1] = $opt[1] === null ? true : $opt[1];
         if (isset($opts[$opt[0]]) === false) {
             $opts[$opt[0]] = array($opt[1]);
         } else {
             $opts[$opt[0]][] = $opt[1];
         }
     }
     $opts_args[0] = $opts;
     return $opts_args;
 }
开发者ID:hiroki-namekawa,项目名称:test-upr,代码行数:51,代码来源:Ethna_Plugin_Handle.php

示例14: dirname

define('P2_FETCH_SUBJECT_TXT_DEBUG_OUTPUT_FILE', '/tmp/p2_fetch_subject_txt.log');
require dirname(__FILE__) . '/../conf/conf.inc.php';
require_once 'Console/Getopt.php';
P2HttpExt::activate();
// }}}
// {{{ コマンドライン引数を取得
$getopt = new Console_Getopt();
$args = $getopt->readPHPArgv();
if (PEAR::isError($args)) {
    fwrite(STDERR, $args->getMessage() . PHP_EOL);
    exit(1);
}
array_shift($args);
$short_options = 'm:s:';
$long_options = array('mode=', 'set=');
$options = $getopt->getopt2($args, $short_options, $long_options);
if (PEAR::isError($options)) {
    fwrite(STDERR, $options->getMessage() . PHP_EOL);
    exit(1);
}
$mode = null;
$set = null;
foreach ($options[0] as $option) {
    switch ($option[0]) {
        case 'm':
        case '--mode':
            $mode = p2_fst_checkopt_mode($option[1]);
            break;
        case 's':
        case '--set':
            $set = p2_fst_checkopt_set($option[1]);
开发者ID:unpush,项目名称:p2-php,代码行数:31,代码来源:fetch-subject-txt.php

示例15: run

function run()
{
    session_start();
    require_once '../civicrm.config.php';
    require_once 'CRM/Core/Config.php';
    $config =& CRM_Core_Config::singleton();
    require_once 'Console/Getopt.php';
    $shortOptions = "n:p:s:e:k:g:parse";
    $longOptions = array('name=', 'pass=', 'key=', 'start=', 'end=', 'geocoding=', 'parse=');
    $getopt = new Console_Getopt();
    $args = $getopt->readPHPArgv();
    array_shift($args);
    list($valid, $dontCare) = $getopt->getopt2($args, $shortOptions, $longOptions);
    $vars = array('start' => 's', 'end' => 'e', 'name' => 'n', 'pass' => 'p', 'key' => 'k', 'geocoding' => 'g', 'parse' => 'ap');
    foreach ($vars as $var => $short) {
        ${$var} = null;
        foreach ($valid as $v) {
            if ($v[0] == $short || $v[0] == "--{$var}") {
                ${$var} = $v[1];
                break;
            }
        }
        if (!${$var}) {
            ${$var} = CRM_Utils_Array::value($var, $_REQUEST);
        }
        $_REQUEST[$var] = ${$var};
    }
    // this does not return on failure
    // require_once 'CRM/Utils/System.php';
    CRM_Utils_System::authenticateScript(true, $name, $pass);
    // do check for geocoding.
    $processGeocode = false;
    if (empty($config->geocodeMethod)) {
        if ($geocoding == 'true') {
            echo ts('Error: You need to set a mapping provider under Global Settings');
            exit;
        }
    } else {
        $processGeocode = true;
        // user might want to over-ride.
        if ($geocoding == 'false') {
            $processGeocode = false;
        }
    }
    // do check for parse street address.
    require_once 'CRM/Core/BAO/Preferences.php';
    $parseAddress = CRM_Utils_Array::value('street_address_parsing', CRM_Core_BAO_Preferences::valueOptions('address_options'), false);
    $parseStreetAddress = false;
    if (!$parseAddress) {
        if ($parse == 'true') {
            echo ts('Error: You need to enable Street Address Parsing under Global Settings >> Address Settings.');
            exit;
        }
    } else {
        $parseStreetAddress = true;
        // user might want to over-ride.
        if ($parse == 'false') {
            $parseStreetAddress = false;
        }
    }
    // don't process.
    if (!$parseStreetAddress && !$processGeocode) {
        echo ts('Error: Both Geocode mapping as well as Street Address Parsing are disabled. You must configure one or both options to use this script.');
        exit;
    }
    $config->userFramework = 'Soap';
    $config->userFrameworkClass = 'CRM_Utils_System_Soap';
    $config->userHookClass = 'CRM_Utils_Hook_Soap';
    // we have an exclusive lock - run the mail queue
    processContacts($config, $processGeocode, $parseStreetAddress, $start, $end);
}
开发者ID:bhirsch,项目名称:civicrm,代码行数:71,代码来源:UpdateAddress.php


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