src/classes/CCConsoleController.php
public static function parse( $cmd ) 
	{	
		// if we dont have an command
		if ( empty( $cmd ) ) 
		{
			return false;
		}
		
		$params = array();
		
		// are we in a string
		$in_string = false;
		$len = strlen( $cmd );
		$crr_prm = "";
		$command_str = $cmd;
		$cmd = array();
		
		// loop trough
		for( $i=0;$len>$i;$i++ ) 
		{
			$char = $command_str[$i];
			switch( $char ) {
				case ' ':
					if ( !$in_string ) 
					{
						$cmd[] = $crr_prm;
						$crr_prm = '';
					} else {
						$crr_prm .= $char;
					}
				break;
				case '"':
					if( $i > 0 && $command_str[$c-1] != '\\' ) 
					{ 
						$in_string = !$in_string; 
					}
				break;
				default:
					$crr_prm .= $char;
				break;
			}
		}
		
		$cmd[] = $crr_prm;
		
		// get the controller
		$controller = array_shift( $cmd );
		
		// get the action
		$action = null;
		
		// check we got an action in our controller
		if ( strpos( $controller, '::' ) !== false ) 
		{
			$controller = explode( '::', $controller );
			$action = $controller[1];
			$controller = $controller[0];
		}
		
		// skipper if we got an named param skip the next
		$skip = false;
		
		// get the params
		foreach( $cmd as $key => $value ) 
		{
			if ( $skip ) 
			{
				$skip = false; continue;
			}
 			
			// named param?
			if ( substr( $value, 0, 1 ) == '-' ) 
			{
				if ( array_key_exists( $key+1, $cmd ) ) 
				{
					$next_value = $cmd[$key+1];
					if ( substr( $next_value, 0, 1 ) == '-' ) 
					{
						$params[substr( $value, 1 )] = true;
					} else {
						$params[substr( $value, 1 )] = $next_value; $skip = true;
					}	
				} else {
					$params[substr( $value, 1 )] = true;
				}
			} else {
				$params[] = $value;
			}
		}
		
		return static::run( trim( $controller ), trim( $action ), $params );
	}
public static function parse( $cmd ) 
	{	
		// if we dont have an command
		if ( empty( $cmd ) ) 
		{
			return false;
		}
		
		$params = array();
		
		// are we in a string
		$in_string = false;
		$len = strlen( $cmd );
		$crr_prm = "";
		$command_str = $cmd;
		$cmd = array();
		
		// loop trough
		for( $i=0;$len>$i;$i++ ) 
		{
			$char = $command_str[$i];
			switch( $char ) {
				case ' ':
					if ( !$in_string ) 
					{
						$cmd[] = $crr_prm;
						$crr_prm = '';
					} else {
						$crr_prm .= $char;
					}
				break;
				case '"':
					if( $i > 0 && $command_str[$c-1] != '\\' ) 
					{ 
						$in_string = !$in_string; 
					}
				break;
				default:
					$crr_prm .= $char;
				break;
			}
		}
		
		$cmd[] = $crr_prm;
		
		// get the controller
		$controller = array_shift( $cmd );
		
		// get the action
		$action = null;
		
		// check we got an action in our controller
		if ( strpos( $controller, '::' ) !== false ) 
		{
			$controller = explode( '::', $controller );
			$action = $controller[1];
			$controller = $controller[0];
		}
		
		// skipper if we got an named param skip the next
		$skip = false;
		
		// get the params
		foreach( $cmd as $key => $value ) 
		{
			if ( $skip ) 
			{
				$skip = false; continue;
			}
 			
			// named param?
			if ( substr( $value, 0, 1 ) == '-' ) 
			{
				if ( array_key_exists( $key+1, $cmd ) ) 
				{
					$next_value = $cmd[$key+1];
					if ( substr( $next_value, 0, 1 ) == '-' ) 
					{
						$params[substr( $value, 1 )] = true;
					} else {
						$params[substr( $value, 1 )] = $next_value; $skip = true;
					}	
				} else {
					$params[substr( $value, 1 )] = true;
				}
			} else {
				$params[] = $value;
			}
		}
		
		return static::run( trim( $controller ), trim( $action ), $params );
	}
public static function parse ( $ cmd ) { // if we dont have an command if ( empty ( $ cmd ) ) { return false ; } $ params = array ( ) ; // are we in a string $ in_string = false ; $ len = strlen ( $ cmd ) ; $ crr_prm = "" ; $ command_str = $ cmd ; $ cmd = array ( ) ; // loop trough for ( $ i = 0 ; $ len > $ i ; $ i ++ ) { $ char = $ command_str [ $ i ] ; switch ( $ char ) { case ' ' : if ( ! $ in_string ) { $ cmd [ ] = $ crr_prm ; $ crr_prm = '' ; } else { $ crr_prm .= $ char ; } break ; case '"' : if ( $ i > 0 && $ command_str [ $ c - 1 ] != '\\' ) { $ in_string = ! $ in_string ; } break ; default : $ crr_prm .= $ char ; break ; } } $ cmd [ ] = $ crr_prm ; // get the controller $ controller = array_shift ( $ cmd ) ; // get the action $ action = null ; // check we got an action in our controller if ( strpos ( $ controller , '::' ) !== false ) { $ controller = explode ( '::' , $ controller ) ; $ action = $ controller [ 1 ] ; $ controller = $ controller [ 0 ] ; } // skipper if we got an named param skip the next $ skip = false ; // get the params foreach ( $ cmd as $ key => $ value ) { if ( $ skip ) { $ skip = false ; continue ; } // named param? if ( substr ( $ value , 0 , 1 ) == '-' ) { if ( array_key_exists ( $ key + 1 , $ cmd ) ) { $ next_value = $ cmd [ $ key + 1 ] ; if ( substr ( $ next_value , 0 , 1 ) == '-' ) { $ params [ substr ( $ value , 1 ) ] = true ; } else { $ params [ substr ( $ value , 1 ) ] = $ next_value ; $ skip = true ; } } else { $ params [ substr ( $ value , 1 ) ] = true ; } } else { $ params [ ] = $ value ; } } return static :: run ( trim ( $ controller ) , trim ( $ action ) , $ params ) ; }
Parse an command and execute console style

@param string		$cmd
Parse an command and execute console style