ENHANCEMENT: Updated argument handling for sake

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63057 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-09-25 04:49:01 +00:00
parent f47d5481ee
commit 13d55cdfc4
2 changed files with 23 additions and 2 deletions

View File

@ -15,8 +15,29 @@ if(isset($_SERVER['HTTP_HOST'])) {
* @subpackage core
*/
/**
* Process arguments and load them into the $_GET and $_REQUEST arrays
* For example,
* sake my/url somearg otherarg key=val --otherkey=val third=val&fourth=val
*
* Will result int he following get data:
* args => array('somearg', 'otherarg'),
* key => val
* otherkey => val
* third => val
* fourth => val
*/
if(isset($_SERVER['argv'][2])) {
parse_str($_SERVER['argv'][2], $_GET);
$args = array_slice($_SERVER['argv'],2);
$_GET = array();
foreach($args as $arg) {
if(strpos($arg,'=') == false) {
$_GET['args'][] = $arg;
} else {
$newItems = parse_str( (substr($arg,0,2) == '--') ? substr($arg,2) : $arg );
$_GET = array_merge($_GET, $newItems);
}
}
$_REQUEST = $_GET;
}

2
sake
View File

@ -89,4 +89,4 @@ fi
################################################################################################
## Basic execution
$php $sapphire/cli-script.php $1 $2
$php $sapphire/cli-script.php ${*}