public static function handleCommand() {
        try {
            global $argv;
            $tokens = array_slice($argv, 1);

            if (empty($tokens)) {
                throw new RuntimeException("Command name is required !!");
            }

            $commandName = (string)$tokens[0];
            $commandTokens = array_slice($tokens, 1);

            $commandParameters = [];
            $currentCommandName = null;

            for ($i = 0; $i < sizeof($commandTokens); $i++) {
                $commandToken = $commandTokens[$i];

                if (substr($commandToken, 0, 2) == '--') {
                    if ($currentCommandName != null) {
                        $commandParameters[$currentCommandName] = true;
                    }
                    $currentCommandName = substr($commandToken, 2);
                }
                else {
                    if ($currentCommandName == null) {
                        throw new RuntimeException("Invalid argument \"$commandToken\". Arguments must start with \"--\"");
                    }
                    $commandParameters[$currentCommandName] = $commandToken;
                    $currentCommandName = null;
                }
            }

            if ($currentCommandName != null) {
                $commandParameters[$currentCommandName] = true;
            }

            self::executeCommand($commandName, $commandParameters);
        }
        catch (CommandNotFoundException $exception) {
            get_logger()->warning($exception->getMessage());
            echo $exception->getMessage() . "\n";
        }
    }
public static function handleCommand() {
        try {
            global $argv;
            $tokens = array_slice($argv, 1);

            if (empty($tokens)) {
                throw new RuntimeException("Command name is required !!");
            }

            $commandName = (string)$tokens[0];
            $commandTokens = array_slice($tokens, 1);

            $commandParameters = [];
            $currentCommandName = null;

            for ($i = 0; $i < sizeof($commandTokens); $i++) {
                $commandToken = $commandTokens[$i];

                if (substr($commandToken, 0, 2) == '--') {
                    if ($currentCommandName != null) {
                        $commandParameters[$currentCommandName] = true;
                    }
                    $currentCommandName = substr($commandToken, 2);
                }
                else {
                    if ($currentCommandName == null) {
                        throw new RuntimeException("Invalid argument \"$commandToken\". Arguments must start with \"--\"");
                    }
                    $commandParameters[$currentCommandName] = $commandToken;
                    $currentCommandName = null;
                }
            }

            if ($currentCommandName != null) {
                $commandParameters[$currentCommandName] = true;
            }

            self::executeCommand($commandName, $commandParameters);
        }
        catch (CommandNotFoundException $exception) {
            get_logger()->warning($exception->getMessage());
            echo $exception->getMessage() . "\n";
        }
    }
public static function handleCommand ( ) { try { global $ argv ; $ tokens = array_slice ( $ argv , 1 ) ; if ( empty ( $ tokens ) ) { throw new RuntimeException ( "Command name is required !!" ) ; } $ commandName = ( string ) $ tokens [ 0 ] ; $ commandTokens = array_slice ( $ tokens , 1 ) ; $ commandParameters = [ ] ; $ currentCommandName = null ; for ( $ i = 0 ; $ i < sizeof ( $ commandTokens ) ; $ i ++ ) { $ commandToken = $ commandTokens [ $ i ] ; if ( substr ( $ commandToken , 0 , 2 ) == '--' ) { if ( $ currentCommandName != null ) { $ commandParameters [ $ currentCommandName ] = true ; } $ currentCommandName = substr ( $ commandToken , 2 ) ; } else { if ( $ currentCommandName == null ) { throw new RuntimeException ( "Invalid argument \"$commandToken\". Arguments must start with \"--\"" ) ; } $ commandParameters [ $ currentCommandName ] = $ commandToken ; $ currentCommandName = null ; } } if ( $ currentCommandName != null ) { $ commandParameters [ $ currentCommandName ] = true ; } self :: executeCommand ( $ commandName , $ commandParameters ) ; } catch ( CommandNotFoundException $ exception ) { get_logger ( ) -> warning ( $ exception -> getMessage ( ) ) ; echo $ exception -> getMessage ( ) . "\n" ; } }
Handles a command
@throws \Exception
Handles a command