protected function satisfyUserChoice() {
        // <APP NAME> --version:
        if (array_key_exists('version', $this->config['options'])) {
            $this->executeCommand('version');
            $this->close();
        }

        // <APP NAME> -v:
        if (count($this->config['args']) === 2 &&
            array_key_exists('v', $this->config['options'])) {
            $this->executeCommand('version');
            $this->close();
        }

        // <APP NAME> <COMMAND>:
        foreach ($this->config['args'] as $arg) {
            if (array_key_exists($arg, $this->config['commands'])) {
                $this->executeCommand($arg);
                $this->close();
            }
        }

        switch (count($this->config['arguments'])) {
            // <APP NAME> [<COMMAND>] [<OPTION>] --help:
            // <APP NAME> [<COMMAND>] [<OPTION>] -h:
            case 0:
                $this->executeCommand('help');
                $this->close();
                break;
            // <APP NAME> <UNKNOWN COMMAND>:
            default:
                throw new RuntimeException(sprintf(
                    'Command "%s" not found',
                    $this->config['arguments'][0]
                ), ExitApp::BAD_USER_INTERACTION);
                break;
        }
    }
protected function satisfyUserChoice() {
        // <APP NAME> --version:
        if (array_key_exists('version', $this->config['options'])) {
            $this->executeCommand('version');
            $this->close();
        }

        // <APP NAME> -v:
        if (count($this->config['args']) === 2 &&
            array_key_exists('v', $this->config['options'])) {
            $this->executeCommand('version');
            $this->close();
        }

        // <APP NAME> <COMMAND>:
        foreach ($this->config['args'] as $arg) {
            if (array_key_exists($arg, $this->config['commands'])) {
                $this->executeCommand($arg);
                $this->close();
            }
        }

        switch (count($this->config['arguments'])) {
            // <APP NAME> [<COMMAND>] [<OPTION>] --help:
            // <APP NAME> [<COMMAND>] [<OPTION>] -h:
            case 0:
                $this->executeCommand('help');
                $this->close();
                break;
            // <APP NAME> <UNKNOWN COMMAND>:
            default:
                throw new RuntimeException(sprintf(
                    'Command "%s" not found',
                    $this->config['arguments'][0]
                ), ExitApp::BAD_USER_INTERACTION);
                break;
        }
    }
protected function satisfyUserChoice ( ) { // <APP NAME> --version: if ( array_key_exists ( 'version' , $ this -> config [ 'options' ] ) ) { $ this -> executeCommand ( 'version' ) ; $ this -> close ( ) ; } // <APP NAME> -v: if ( count ( $ this -> config [ 'args' ] ) === 2 && array_key_exists ( 'v' , $ this -> config [ 'options' ] ) ) { $ this -> executeCommand ( 'version' ) ; $ this -> close ( ) ; } // <APP NAME> <COMMAND>: foreach ( $ this -> config [ 'args' ] as $ arg ) { if ( array_key_exists ( $ arg , $ this -> config [ 'commands' ] ) ) { $ this -> executeCommand ( $ arg ) ; $ this -> close ( ) ; } } switch ( count ( $ this -> config [ 'arguments' ] ) ) { // <APP NAME> [<COMMAND>] [<OPTION>] --help: // <APP NAME> [<COMMAND>] [<OPTION>] -h: case 0 : $ this -> executeCommand ( 'help' ) ; $ this -> close ( ) ; break ; // <APP NAME> <UNKNOWN COMMAND>: default : throw new RuntimeException ( sprintf ( 'Command "%s" not found' , $ this -> config [ 'arguments' ] [ 0 ] ) , ExitApp :: BAD_USER_INTERACTION ) ; break ; } }
Try to find out what the user wants

@throws Exception on error
Try to find out what the user wants