Source for file Ethna_Plugin_Handle.php
Documentation is available at Ethna_Plugin_Handle.php
// vim: foldmethod=marker
* Ethna_Plugin_Handle.php
* @author Masaki Fujimoto <fujimoto@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
require_once ETHNA_BASE .
'/class/Ethna_Getopt.php';
// {{{ Ethna_Plugin_Handle
* @author Masaki Fujimoto <fujimoto@php.net>
/** @var command line arguments */
* Ethna_Handle constructor (stub for php4)
$id =
preg_replace('/^([A-Z])/e', "strtolower('\$1')", $id);
$id =
preg_replace('/([A-Z])/e', "'-' . strtolower('\$1')", $id);
* get handler's description
return "description of " .
$this->id;
return "usage of " .
$this->id;
* @param array $lopts long options
* @return array list($opts, $args)
function &_getopt($lopts =
array())
// ex: $lopts = array('foo', 'bar=');
foreach ($lopts as $lopt) {
if ($lopt{strlen($lopt) -
2} ===
'=') {
$sopts .=
$lopt{0} .
'::';
} else if ($lopt{strlen($lopt) -
1} ===
'=') {
$sopts .=
$lopt{0} .
':';
$opt_def[$lopt{0}] =
$lopt;
$opts_args =
$opt->getopt($this->arg_list, $sopts, $lopts);
// ex: "-ff --bar=baz" gets
// $opts = array('foo' => array(true, true),
// 'bar' => array('baz'));
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]);
$opts[$opt[0]][] =
$opt[1];
Documentation generated on Fri, 11 Nov 2011 04:00:20 +0900 by phpDocumentor 1.4.3