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


PHP Console_Getopt类代码示例

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


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

示例1: 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

示例2: __construct

 /**
  * 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

示例3: __construct

 /**
  * 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

示例4: getParameters

 public function getParameters()
 {
     $params = array();
     sgAutoloader::loadFile('Console_Getopt', dirname(__FILE__) . '/vendor/Console/Getopt.php');
     $cg = new Console_Getopt();
     $params = $cg->readPHPArgv();
     array_shift($params);
     return $params;
 }
开发者ID:superglue,项目名称:Superglue,代码行数:9,代码来源:sgCLI.class.php

示例5: __construct

 public function __construct()
 {
     require_once 'Console/Getopt.php';
     define('NO_ARGS', 1);
     define('INVALID_OPTION', 2);
     $args = Console_Getopt::readPHPArgv();
     if (count($args) <= 1) {
         $this->usage(true);
         exit(1);
     }
     if (PEAR::isError($args)) {
         fputs(STDERR, $args->getMessage() . "\n");
         exit(NO_ARGS);
     }
     if ($_SERVER['argv'][0] == $_SERVER['SCRIPT_NAME']) {
         $this->opts = Console_Getopt::getOpt($args, $this->short_opts, $this->long_opts);
     } else {
         $this->opts = Console_Getopt::getOpt2($args, $this->short_opts, $this->long_opts);
     }
     // Are the passed options valid?
     if (PEAR::isError($this->opts)) {
         fputs(STDERR, $this->opts->getMessage() . "\n");
         exit(INVALID_OPTION);
     }
     $this->set_cache();
 }
开发者ID:BackupTheBerlios,项目名称:pobs-svn,代码行数:26,代码来源:getopts.class.php

示例6: _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
  * @access private
  */
 function _parseArgs($argv, $short_options, $long_options = null)
 {
     if (!is_array($argv) && $argv !== null) {
         $argv = preg_split('/\\s+/', ': ' . $argv);
     }
     return Console_Getopt::getopt($argv, $short_options);
 }
开发者ID:BackupTheBerlios,项目名称:logicalframe,代码行数:16,代码来源:System.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
  */
 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

示例8: start

 /**
  * @param  array $arguments
  * @access protected
  */
 protected function start($arguments)
 {
     $wait = false;
     $possibleOptions = array('help', 'version', 'wait');
     $options = Console_Getopt::getopt($arguments, '', $possibleOptions);
     foreach ($options[0] as $option) {
         switch ($option[0]) {
             case '--help':
                 $this->showHelp();
                 exit(self::SUCCESS_EXIT);
                 break;
             case '--version':
                 print PHPUnit2_Runner_Version::getVersionString() . "\n";
                 exit(self::SUCCESS_EXIT);
                 break;
             case '--wait':
                 $wait = true;
                 break;
         }
     }
     $test = isset($options[1][0]) ? $options[1][0] : false;
     if ($test === false) {
         $this->showHelp();
         exit(self::SUCCESS_EXIT);
     }
     try {
         return $this->doRun($this->getTest($test), $wait);
     } catch (Exception $e) {
         throw new Exception('Could not create and run test suite: ' . $e->getMessage());
     }
 }
开发者ID:nateirwin,项目名称:custom-historic,代码行数:35,代码来源:TestRunner.php

示例9: Console_Getopt

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

示例10: 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

示例11: Console_Getopt

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

示例12: 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

示例13: executeDoctrineCli

 public function executeDoctrineCli($arguments = array(), $options = array())
 {
     try {
         DoctrinePluginConfiguration::init();
     } catch (Exception $e) {
         sgCLI::error($e->getMessage());
         return false;
     }
     // spl_autoload_register(array('Doctrine', 'modelsAutoload'));
     spl_autoload_register(array('Doctrine', 'extensionsAutoload'));
     $settings = sgConfiguration::get('settings.DoctrinePlugin');
     $settings['generate_models_options']['suffix'] = '.class.php';
     $config = array('data_fixtures_path' => DoctrinePluginConfiguration::getPath('fixtures'), 'models_path' => DoctrinePluginConfiguration::getPath('models'), 'migrations_path' => DoctrinePluginConfiguration::getPath('mogrations'), 'sql_path' => DoctrinePluginConfiguration::getPath('sql'), 'yaml_schema_path' => DoctrinePluginConfiguration::getPath('schema'), 'generate_models_options' => $settings['generate_models_options']);
     $cg = new Console_Getopt();
     $params = $cg->readPHPArgv();
     $params[0] .= ' ' . $params[1];
     unset($params[1]);
     $params = array_merge($params);
     $cli = new DoctrinePluginCli($config);
     $cli->run($params);
 }
开发者ID:superglue,项目名称:DoctrinePlugin,代码行数:21,代码来源:DoctrineTask.class.php

示例14: 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

示例15: 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


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