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


PHP Console_Getopt::doGetopt方法代码示例

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


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

示例1: getopt

 /**
  * Gets the options and parameters from the command arguments
  *
  * Extracts the command arguments. Tidies the options.
  * Builds the help/usage text.
  *
  * @param  array   $config      the command configuration
  * @param  boolean $toLongNames Converts options names to long names if true,
  *                              e.g. "align", or to short names if false,
  *                              e.g. "A", default is true
  * @param  boolean $asKeys      return options with the names used as array
  *                              keys if true, or leave them as returned by
  *                              Console_Getopt::doGetopt(), default is true
  * @param  integer $version     Console_Getopt::doGetopt version
  * @return array   the options and parameters
  * @access public
  * @static
  */
 public static function getopt($config = array(), $toLongNames = true, $asKeys = true, $version = 2)
 {
     $getopt = new self();
     // silently ignore invalid configuration arrays, defaults the absent ones to empty arrays
     $default = array_combine($getopt->configKeys, array_fill(0, count($getopt->configKeys), array()));
     $config = array_intersect_key($config, $default);
     $config = array_merge($default, $config);
     // extracts the command arguments, including the command name
     $args = Console_Getopt::readPHPArgv();
     $command = array_shift($args);
     // tidies the options, sets the short and long options, and calls getopt
     $config['options'] = $getopt->tidyOptions($config['options']);
     $options = Console_Getopt::doGetopt($version, $args, $getopt->shortOptions, $getopt->longOptions);
     // a syntax error, prints out the error message
     PEAR::isError($options) and exit($options->getMessage());
     // tidies the arguments
     $options[0] = $getopt->tidyArgs($options[0], $toLongNames, $asKeys);
     // a request for help/usage, prints the command usage
     $options[0] == 'help' and exit(implode("\n", $getopt->setHelp($config, $command)));
     return $options;
 }
开发者ID:ookwudili,项目名称:chisimba,代码行数:39,代码来源:GetoptPlus.php

示例2: getopt

 /**
  * This function expects $args to start with the script name (POSIX-style).
  * Preserved for backwards compatibility.
  * @see getopt2()
  */
 function getopt($args, $short_options, $long_options = null)
 {
     return Console_Getopt::doGetopt(1, $args, $short_options, $long_options);
 }
开发者ID:BackupTheBerlios,项目名称:rheinaufcms-svn,代码行数:9,代码来源:Getopt.php

示例3: getopt

 /**
  * This function expects $args to start with the script name (POSIX-style).
  * Preserved for backwards compatibility.
  *
  * @param array  $args          an array of command-line arguments
  * @param string $short_options specifies the list of allowed short options
  * @param array  $long_options  specifies the list of allowed long options
  *
  * @see getopt2()
  * @return array two-element array containing the list of parsed options and
  * the non-option arguments
  */
 function getopt($args, $short_options, $long_options = null, $skip_unknown = false)
 {
     return Console_Getopt::doGetopt(1, $args, $short_options, $long_options, $skip_unknown);
 }
开发者ID:rrsc,项目名称:freemed,代码行数:16,代码来源:Getopt.php


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