import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ArgumentParser.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: ArgumentParser.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -31,9 +31,9 @@ require_once 'Zend/Console/Getopt.php';
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Framework_Registry_EnabledInterface
|
||||
class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Framework_Registry_EnabledInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var Zend_Tool_Framework_Registry_Interface
|
||||
*/
|
||||
@ -63,8 +63,8 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
protected $_helpKnownAction = false;
|
||||
protected $_helpKnownProvider = false;
|
||||
protected $_helpKnownSpecialty = false;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* setArguments
|
||||
*
|
||||
@ -76,7 +76,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
$this->_argumentsOriginal = $this->_argumentsWorking = $arguments;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setRegistry()
|
||||
*
|
||||
@ -87,14 +87,14 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
{
|
||||
// get the client registry
|
||||
$this->_registry = $registry;
|
||||
|
||||
|
||||
// set manifest repository, request, response for easy access
|
||||
$this->_manifestRepository = $this->_registry->getManifestRepository();
|
||||
$this->_request = $this->_registry->getRequest();
|
||||
$this->_response = $this->_registry->getResponse();
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse() - This method does the work of parsing the arguments into the enpooint request,
|
||||
* this will also (during help operations) fill the response in with information as needed
|
||||
@ -108,10 +108,10 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
require_once 'Zend/Tool/Framework/Client/Exception.php';
|
||||
throw new Zend_Tool_Framework_Client_Exception('The client registry must have both a request and response registered.');
|
||||
}
|
||||
|
||||
|
||||
// setup the help options
|
||||
$helpResponseOptions = array();
|
||||
|
||||
|
||||
// check to see if the first cli arg is the script name
|
||||
if ($this->_argumentsWorking[0] == $_SERVER['SCRIPT_NAME' ]) {
|
||||
array_shift($this->_argumentsWorking);
|
||||
@ -128,7 +128,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
// ensure there are arguments left
|
||||
if (count($this->_argumentsWorking) == 0) {
|
||||
$this->_request->setDispatchable(false); // at this point request is not dispatchable
|
||||
|
||||
|
||||
// check to see if this was a help request
|
||||
if ($this->_help) {
|
||||
$this->_createHelpResponse();
|
||||
@ -149,17 +149,17 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
|
||||
if ($this->_helpKnownAction) {
|
||||
$helpResponseOptions = array_merge(
|
||||
$helpResponseOptions,
|
||||
$helpResponseOptions,
|
||||
array('actionName' => $this->_request->getActionName())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/* @TODO Action Parameter Requirements */
|
||||
|
||||
// make sure there are more "words" on the command line
|
||||
if (count($this->_argumentsWorking) == 0) {
|
||||
$this->_request->setDispatchable(false); // at this point request is not dispatchable
|
||||
|
||||
|
||||
// check to see if this is a help request
|
||||
if ($this->_help) {
|
||||
$this->_createHelpResponse($helpResponseOptions);
|
||||
@ -169,7 +169,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// process the provider part of the command line
|
||||
try {
|
||||
$this->_parseProviderPart();
|
||||
@ -178,21 +178,21 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
$this->_createHelpResponse(array('error' => $exception->getMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ($this->_helpKnownProvider) {
|
||||
$helpResponseOptions = array_merge(
|
||||
$helpResponseOptions,
|
||||
$helpResponseOptions,
|
||||
array('providerName' => $this->_request->getProviderName())
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->_helpKnownSpecialty) {
|
||||
$helpResponseOptions = array_merge(
|
||||
$helpResponseOptions,
|
||||
$helpResponseOptions,
|
||||
array('specialtyName' => $this->_request->getSpecialtyName())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// if there are arguments on the command line, lets process them as provider options
|
||||
if (count($this->_argumentsWorking) != 0) {
|
||||
$this->_parseProviderOptionsPart();
|
||||
@ -234,7 +234,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
$getoptOptions['pretend|p'] = 'PRETEND';
|
||||
$getoptOptions['debug|d'] = 'DEBUG';
|
||||
$getoptParser = new Zend_Console_Getopt($getoptOptions, $this->_argumentsWorking, array('parseAll' => false));
|
||||
|
||||
|
||||
// @todo catch any exceptions here
|
||||
$getoptParser->parse();
|
||||
|
||||
@ -247,7 +247,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
$this->_request->setVerbose(true);
|
||||
} else {
|
||||
$property = '_'.$option;
|
||||
$this->{$property} = true;
|
||||
$this->{$property} = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,7 +313,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
$this->_help = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// get the cli provider names from the manifest
|
||||
$providerMetadata = $this->_manifestRepository->getMetadata(array(
|
||||
'type' => 'Tool',
|
||||
@ -331,15 +331,15 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
|
||||
$this->_helpKnownProvider = true;
|
||||
$this->_request->setProviderName($providerMetadata->getProviderName());
|
||||
|
||||
|
||||
if ($consoleSpecialtyName == '?') {
|
||||
$this->_help = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$providerSpecialtyMetadata = $this->_manifestRepository->getMetadata(array(
|
||||
'type' => 'Tool',
|
||||
'name' => 'specialtyName',
|
||||
'type' => 'Tool',
|
||||
'name' => 'specialtyName',
|
||||
'value' => $consoleSpecialtyName,
|
||||
'providerName' => $providerMetadata->getProviderName(),
|
||||
'clientName' => 'console'
|
||||
@ -368,7 +368,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
$this->_help = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$searchParams = array(
|
||||
'type' => 'Tool',
|
||||
'providerName' => $this->_request->getProviderName(),
|
||||
@ -399,10 +399,10 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
|
||||
// process ParameterInfo into array for command line option matching
|
||||
if ($parameterInfo['type'] == 'string' || $parameterInfo['type'] == 'bool') {
|
||||
$optionConfig .= $paramNameShortValues[$parameterNameLong]
|
||||
$optionConfig .= $paramNameShortValues[$parameterNameLong]
|
||||
. (($parameterInfo['optional']) ? '-' : '=') . 's';
|
||||
} elseif (in_array($parameterInfo['type'], array('int', 'integer', 'float'))) {
|
||||
$optionConfig .= $paramNameShortValues[$parameterNameLong]
|
||||
$optionConfig .= $paramNameShortValues[$parameterNameLong]
|
||||
. (($parameterInfo['optional']) ? '-' : '=') . 'i';
|
||||
} else {
|
||||
$optionConfig .= $paramNameShortValues[$parameterNameLong] . '-s';
|
||||
@ -467,7 +467,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
$this->_metadataProviderOptionsLong = $actionableMethodLongParamsMetadata;
|
||||
$this->_metadataProviderOptionsShort = $actionableMethodShortParamsMetadata;
|
||||
*/
|
||||
|
||||
|
||||
$this->_argumentsWorking = $getoptParser->getRemainingArgs();
|
||||
|
||||
return;
|
||||
@ -483,11 +483,11 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
require_once 'Zend/Tool/Framework/Client/Console/HelpSystem.php';
|
||||
$helpSystem = new Zend_Tool_Framework_Client_Console_HelpSystem();
|
||||
$helpSystem->setRegistry($this->_registry);
|
||||
|
||||
|
||||
if (isset($options['error'])) {
|
||||
$helpSystem->respondWithErrorMessage($options['error']);
|
||||
}
|
||||
|
||||
|
||||
if (isset($options['actionName']) && isset($options['providerName'])) {
|
||||
$helpSystem->respondWithSpecialtyAndParamHelp($options['providerName'], $options['actionName']);
|
||||
} elseif (isset($options['actionName'])) {
|
||||
|
Reference in New Issue
Block a user