From 13d55cdfc4f7244928318bc09efd78b6bcf2a701 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 25 Sep 2008 04:49:01 +0000 Subject: [PATCH] ENHANCEMENT: Updated argument handling for sake git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63057 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- cli-script.php | 23 ++++++++++++++++++++++- sake | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/cli-script.php b/cli-script.php index eebecd891..577278b43 100755 --- a/cli-script.php +++ b/cli-script.php @@ -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; } diff --git a/sake b/sake index 643c78d33..3205407b7 100755 --- a/sake +++ b/sake @@ -89,4 +89,4 @@ fi ################################################################################################ ## Basic execution -$php $sapphire/cli-script.php $1 $2 +$php $sapphire/cli-script.php ${*} \ No newline at end of file