• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Console_Getopt类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getParams

 /**
  *
  */
 public function getParams()
 {
     $short_opts = 'hdcsl';
     $long_opts = array('help', 'debug', 'compress', 'strict', 'lexdebug');
     $console = new Console_Getopt();
     $args = $console->readPHPArgv();
     $opts = $console->getopt($args, $short_opts, $long_opts);
     if (PEAR::isError($opts)) {
         echo $opts->getMessage() . PHP_EOL;
         $this->usage(1);
     }
     foreach ($opts[0] as $opt) {
         if ($opt[0] === '--help' || $opt[0] === 'h') {
             $this->usage();
         }
         if ($opt[0] === '--debug' || $opt[0] === 'd') {
             SmartCSS::$debug = true;
         }
         if ($opt[0] === '--compress' || $opt[0] === 'c') {
             SmartCSS::$compress = true;
         }
         if ($opt[0] === '--strict' || $opt[0] === 's') {
             SmartCSS::$strict = true;
         }
         if ($opt[0] === '--lexdebug' || $opt[0] === 'l') {
             SmartCSS::$lexdebug = true;
         }
     }
     if (empty($opts[1])) {
         $this->usage();
     }
     $filename = $opts[1][0];
     if (empty($filename)) {
         $this->usage();
     }
     return $filename;
 }
开发者ID:nekoya,项目名称:SmartCSS,代码行数:40,代码来源:CLI.class.php


示例17: run

  function run(&$root_group)
  {
    $opt_browse_path = false;
    $opt_test_path = false;

    $argv = Console_Getopt::readPHPArgv();
    if (PEAR::isError($argv))
    {
      die('Fatal Error: ' . $argv->getMessage()) . "\n";
    }

    $short_opts = 'ht:b:';
    $long_opts = array('help', 'test=', 'browse=');
    $options = Console_Getopt::getopt($argv, $short_opts, $long_opts);
    if (PEAR::isError($options))
    {
      $this->usage();
    }

    foreach ($options[0] as $option)
    {
      switch ($option[0])
      {
        case 'h':
        case '--help':
          $this->usage();
          break;
        case 't':
        case '--test':
          $opt_test_path = $option[1];
          break;
        case 'b':
        case '--browse':
          $opt_browse_path = $option[1];
          break;
      }
    }

    if ($opt_browse_path)
      $this->browse($opt_browse_path, $root_group);

    if ($opt_test_path)
      $this->perform($opt_test_path, $root_group);

    if(!$opt_browse_path && !$opt_test_path)
      $this->browse('', $root_group);

    exit(0);
  }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:49,代码来源:cli_test_runner.class.php


示例18: _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


示例19: parseArgs

 function parseArgs()
 {
     // mapp of keys to values..
     $args = Console_Getopt::ReadPHPArgV();
     $vals = Console_Getopt::getopt($args, '');
     //print_r($vals);
     $files = $vals[1];
     if (!$files) {
         $this->error(0, "No Files supplied");
     }
     foreach ($files as $file) {
         $realpath = realpath($file);
         if (!$realpath) {
             $this->error(0, "File {$path} Does not exist");
         }
         $this->files[] = $realpath;
     }
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:18,代码来源:Test.php


示例20: main

 public static function main()
 {
     $options = Console_Getopt::getopt($_SERVER['argv'], '', array('wait'));
     if (PEAR::isError($options)) {
         // ...
         exit;
     }
     $test = isset($options[1][0]) ? $options[1][0] : false;
     $wait = isset($options[0][0][0]) ? true : false;
     if ($test) {
         $testRunner = new PHPUnit_TextUI_TestRunner();
         try {
             $result = $testRunner->doRun($testRunner->getTest($test), $wait);
         } catch (Exception $e) {
             // ...
         }
     } else {
         // ...
     }
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:20,代码来源:TestRunner.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Constants类代码示例发布时间:2022-05-23
下一篇:
PHP Console_CommandLine类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap