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


PHP Console_Getopt::getopt方法代码示例

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


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

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

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

示例3: exit

 /**
  * Constructor will parse specified short and long arguments
  *
  * @access public
  * @param  string   short options specification
  * @param  array    long options specification
  * @param  callback error callback, call this and exit on errors if given
  */
 function __construct($short_options, $long_options = NULL, $usage = NULL)
 {
     // use parent methods for actual parsing, store result internaly
     $argv = parent::readPHPArgv();
     $this->options = parent::getopt($argv, $short_options, $long_options);
     if (PEAR::isError($this->options)) {
         if (!is_null($usage) && is_callable($usage)) {
             call_user_func($usage, $this->options->message);
             exit(3);
         }
     }
 }
开发者ID:vinnivinsachi,项目名称:Vincent-DR,代码行数:20,代码来源:Getopt.php

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

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

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

示例7: parseParams

 protected function parseParams($namespace, $task, $cliParams = array())
 {
     sgAutoloader::loadFile('Console_Getopt', dirname(__FILE__) . '/vendor/Console/Getopt.php');
     $arguments = array();
     $options = array();
     $taskDefinition = self::getTask($namespace, $task);
     if (isset($taskDefinition['options']) || isset($taskDefinition['arguments'])) {
         if (!isset($taskDefinition['arguments'])) {
             $taskDefinition['arguments'] = array();
         }
         if (!isset($taskDefinition['options']['short'])) {
             $taskDefinition['options']['short'] = null;
         }
         if (!isset($taskDefinition['options']['long'])) {
             $taskDefinition['options']['long'] = array();
         }
         try {
             $params = Console_Getopt::getopt($cliParams, $taskDefinition['options']['short'], $taskDefinition['options']['long']);
             if (!empty($taskDefinition['arguments']) && (!isset($params[1]) || count($taskDefinition['arguments']) !== count($params[1]))) {
                 throw new Exception('Missing required argument.');
             }
             $arguments = array();
             if (!empty($taskDefinition['arguments'])) {
                 $arguments = array_combine($taskDefinition['arguments'], $params[1]);
             }
             $options = array();
             foreach ($params[0] as $param) {
                 $options[$param[0]] = $param[1];
             }
         } catch (Exception $e) {
             $error = array();
             $error[] = $e->getMessage();
             if (isset($taskDefinition['usage'])) {
                 $error[] = 'Usage: ' . $taskDefinition['usage'];
             }
             sgCLI::error($error);
             return false;
         }
     }
     return array('arguments' => $arguments, 'options' => $options);
 }
开发者ID:superglue,项目名称:Superglue,代码行数:41,代码来源:sgTask.class.php

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

示例9: realpath

Usage: docgen.php [options] output-directory
Options:

  --plugin=...     build docs for given plugin instead of core


ENDOFHELP;
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
set_include_path(INSTALLDIR . DIRECTORY_SEPARATOR . 'extlib' . PATH_SEPARATOR . get_include_path());
$pattern = "*.php *.inc";
$exclude = 'config.php */extlib/* */local/* */plugins/* */scripts/*';
$plugin = false;
require_once 'Console/Getopt.php';
$parser = new Console_Getopt();
$result = $parser->getopt($_SERVER['argv'], $shortoptions, $longoptions);
if (PEAR::isError($result)) {
    print $result->getMessage() . "\n";
    exit(1);
}
list($options, $args) = $result;
foreach ($options as $option) {
    $arg = $option[0];
    if ($arg == '--plugin') {
        $plugin = $options[1];
    } else {
        if ($arg == 'h' || $arg == '--help') {
            print $helptext;
            exit(0);
        }
    }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:30,代码来源:docgen.php

示例10: die

<?php

require "Getopt.php";
require "scheme.php";
$result = Console_Getopt::getopt($argv, 'p');
if (!$result || count($result[1]) < 3) {
    die("usage: php merge-defs.php [-p] generated-defs old-defs\n");
}
$merge_params = false;
list($opts, $argv) = $result;
foreach ($opts as $opt) {
    if ($opt[0] == 'p') {
        $merge_params = true;
    }
}
class Merge_Parser extends Defs_Parser
{
    function handle_include()
    {
        /* pass */
    }
}
$new_defs = new Merge_Parser($argv[1]);
$old_defs = new Merge_Parser($argv[2]);
$new_defs->start_parsing();
$old_defs->start_parsing();
$new_defs->merge($old_defs, $merge_params);
$new_defs->write_defs();
开发者ID:laiello,项目名称:oscats,代码行数:28,代码来源:merge_defs.php

示例11: array

// Use $_SERVER if available.
if (isset($_SERVER)) {
    $argc = $_SERVER['argc'];
    $argv = $_SERVER['argv'];
} else {
    $argc = $HTTP_SERVER_VARS['argc'];
    $argv = $HTTP_SERVER_VARS['argv'];
}
$GLOBALS['docgenstats'] = array('classes' => 0, 'constructors' => 0, 'functions' => 0, 'properties' => 0, 'signals' => 0);
/* An ugly hack to counteract PHP's pernicious desire to treat + as an argument
   separator in command-line version. */
// I don't need this. It causes trouble.
// array_walk($argv, create_function('&$x', '$x = urldecode($x);'));
// Use PEAR::Console_Getopt to get the arguments from the
// command line.
$result = Console_Getopt::getopt($argv, 'o:p:r:d:s:l:u');
if (!$result || count($result[1]) < 2) {
    // Set up the help message.
    die("Usage: php -q generator.php [OPTION] defsfile [class ...]\n\n" . "  -o <file>         use overrides in <file>\n" . "  -p <prefix>       use <prefix> for docs\n" . "  -r <file>         register types from <file>\n" . "  -d <path>         output files to this directory\n" . "  -s <path>         documentation dir\n" . "  -l <lang>         Language\n" . "  -u                Update existing docs\n");
}
list($opts, $argv) = $result;
// Set the default options.
$prefix = 'gtk';
$overrides = new Overrides();
$lang = 'en';
$update_docs = FALSE;
// Override the defaults with the command line options.
foreach ($opts as $opt) {
    list($opt_spec, $opt_arg) = $opt;
    if ($opt_spec == 'o') {
        $overrides = new Overrides($opt_arg);
开发者ID:rakotomandimby,项目名称:php-gtk-src,代码行数:31,代码来源:docgen.php

示例12: prepare

 /**
  * Get our input parameters...
  * @return boolean success
  */
 function prepare()
 {
     $shortoptions = 'qvh';
     $longoptions = array('quiet', 'verbose', 'help', 'skip-config');
     $map = array('-s' => 'server', '--server' => 'server', '-p' => 'path', '--path' => 'path', '--sitename' => 'sitename', '--fancy' => 'fancy', '--ssl' => 'ssl', '--dbtype' => 'dbtype', '--host' => 'host', '--database' => 'database', '--username' => 'username', '--password' => 'password', '--admin-nick' => 'adminNick', '--admin-pass' => 'adminPass', '--admin-email' => 'adminEmail', '--site-profile' => 'siteProfile');
     foreach ($map as $arg => $target) {
         if (substr($arg, 0, 2) == '--') {
             $longoptions[] = substr($arg, 2) . '=';
         } else {
             $shortoptions .= substr($arg, 1) . ':';
         }
     }
     $parser = new Console_Getopt();
     $result = $parser->getopt($_SERVER['argv'], $shortoptions, $longoptions);
     if (PEAR::isError($result)) {
         $this->warning($result->getMessage());
         return false;
     }
     list($options, $args) = $result;
     // defaults
     $this->dbtype = 'mysql';
     $this->verbose = true;
     // ssl is defaulted in lib/installer.php
     foreach ($options as $option) {
         $arg = $option[0];
         if (isset($map[$arg])) {
             $var = $map[$arg];
             $this->{$var} = $option[1];
             if ($arg == '--fancy') {
                 $this->{$var} = $option[1] != 'false' && $option[1] != 'no';
             }
         } else {
             if ($arg == '--skip-config') {
                 $this->skipConfig = true;
             } else {
                 if ($arg == 'q' || $arg == '--quiet') {
                     $this->verbose = false;
                 } else {
                     if ($arg == 'v' || $arg == '--verbose') {
                         $this->verbose = true;
                     } else {
                         if ($arg == 'h' || $arg == '--help') {
                             // will go back to show help
                             return false;
                         }
                     }
                 }
             }
         }
     }
     $fail = false;
     if (empty($this->server)) {
         $this->updateStatus("You must specify a web server for the site.", true);
         // path is optional though
         $fail = true;
     }
     if (!$this->validateDb()) {
         $fail = true;
     }
     if (!$this->validateAdmin()) {
         $fail = true;
     }
     return !$fail;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:68,代码来源:install_cli.php

示例13: define

 */
define('AUTH_HANDLER', true);
define('HORDE_BASE', __DIR__ . '/../../');
define('BEATNIK_BASE', HORDE_BASE . '/beatnik');
// Do CLI checks and environment setup first.
require_once HORDE_BASE . '/lib/core.php';
// Make sure no one runs this from the web.
if (!Horde_CLI::runningFromCLI()) {
    exit("Must be run from the command line\n");
}
// Load the CLI environment.
$cli = Horde_Cli::init();
// We accept the user name on the command-line.
require_once 'Console/Getopt.php';
try {
    Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'h:u:p:t:r', array('help', 'username=', 'password=', 'type=', 'rpc='));
} catch (Exception $e) {
    $error = _("Couldn't read command-line options.");
    Horde::log($error, 'DEBUG');
    $cli->fatal($error);
}
// Show help and exit if no arguments were set.
list($opts, $args) = $ret;
if (!$opts) {
    showHelp();
    exit;
}
foreach ($opts as $opt) {
    list($optName, $optValue) = $opt;
    switch ($optName) {
        case 'u':
开发者ID:raz0rsdge,项目名称:horde,代码行数:31,代码来源:export_config.php

示例14: array

// get log object
$oLog = PHP_Beautifier_Common::getLog();
//default_options
$aInputFiles = STDIN;
$sOutputFile = STDOUT;
$sIndentChar = ' ';
$iIndentNumber = 4;
$aFilters = array();
$bRecursive = false;
$sCompress = false;
$aFiltersDirectory = array();
$iVerbose = PEAR_LOG_WARNING;
//end default_options
$argv = Console_Getopt::readPHPArgv();
$aLongOptions = array('input=', 'output=', 'indent_tabs==', 'indent_spaces==', 'filters=', 'directory_filters=', 'recursive', 'help', 'compress==', 'verbose');
$options = Console_Getopt::getopt($argv, "f:o:d:l:t::s::c::r?hv", $aLongOptions);
if (PEAR::isError($options)) {
    usage($options);
}
foreach ($options[0] as $opt) {
    $sArgument = str_replace('-', '', $opt[0]);
    $sParam = $opt[1];
    $oLog->log("Arg: " . $sArgument . "[{$sParam}]", PEAR_LOG_DEBUG);
    switch ($sArgument) {
        case 'input':
        case 'f':
            $aInputFiles = $sParam == '-' ? STDIN : array($sParam);
            break;
        case 'output':
        case 'o':
            $sOutputFile = $sParam == '-' ? STDOUT : $sParam;
开发者ID:Webaib,项目名称:org.phpsrc.eclipse.pti.tool.phpbeautifier,代码行数:31,代码来源:php_beautifier.php

示例15: join

#!/usr/bin/env php
<?php 
$php = "php";
set_include_path("test/framework/external/" . PATH_SEPARATOR . "test/framework/" . get_include_path());
require_once "lib/header.php";
require_once "Console/Getopt.php";
require_once "Reduce.php";
$cg = new Console_Getopt();
$command_line = join(" ", $cg->readPHPArgv());
$opt_result = $cg->getopt($cg->readPHPArgv(), "vhc:rdDf:i:UuF:ZP:m:p:");
if (!is_array($opt_result)) {
    die($opt_result->message . "\n");
}
list($opts, $arguments) = $opt_result;
$opt_verbose = 0;
$opt_help = false;
$opt_command = "";
$opt_main_command = "";
$opt_pass = "AST-to-HIR";
$opt_xml = NULL;
$opt_interpret = false;
$opt_dont_upper = false;
$opt_upper = false;
$opt_failure = false;
$opt_zero = true;
$opt_phc_prefix = ".";
foreach ($opts as $opt) {
    switch ($opt[0]) {
        case 'h':
            $opt_help = true;
            break;
开发者ID:michaelprem,项目名称:phc,代码行数:31,代码来源:old_driver.php


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