src/Handler.php
public function parse($inputArgs = null) {
        $args = $this->getCommandLineArgs($inputArgs);
        if (count($args)) {
            $this->scriptName = array_shift($args);
        }

        // build help option
        $helpOpt = false;
        if ($this->helpLong) {
            $helpOpt = new Option();
            $helpOpt->long($this->helpLong);
        }
        if ($this->helpShort) {
            if (!$helpOpt) {
                $helpOpt = new Option();
            }
            $helpOpt->short($this->helpShort);
        }
        if ($helpOpt) {
            $this->configOpts[Parser::HELP_OPTION_NAME] = $helpOpt;
        }

        try {
            $parser = new Parser($this->configOpts, $this->configArgs);
            $parser->parse($args);
        }
        catch (UsageException $e) {
            if ($this->errorHandling) {
                $this->handleUsageError($e);
            }
            else {
                // re-throw exception
                throw $e;
            }
        }
        catch (ShowHelpException $e) {
            $this->showHelp();
        }

        $this->result = $parser->getResult();
    }
public function parse($inputArgs = null) {
        $args = $this->getCommandLineArgs($inputArgs);
        if (count($args)) {
            $this->scriptName = array_shift($args);
        }

        // build help option
        $helpOpt = false;
        if ($this->helpLong) {
            $helpOpt = new Option();
            $helpOpt->long($this->helpLong);
        }
        if ($this->helpShort) {
            if (!$helpOpt) {
                $helpOpt = new Option();
            }
            $helpOpt->short($this->helpShort);
        }
        if ($helpOpt) {
            $this->configOpts[Parser::HELP_OPTION_NAME] = $helpOpt;
        }

        try {
            $parser = new Parser($this->configOpts, $this->configArgs);
            $parser->parse($args);
        }
        catch (UsageException $e) {
            if ($this->errorHandling) {
                $this->handleUsageError($e);
            }
            else {
                // re-throw exception
                throw $e;
            }
        }
        catch (ShowHelpException $e) {
            $this->showHelp();
        }

        $this->result = $parser->getResult();
    }
public function parse ( $ inputArgs = null ) { $ args = $ this -> getCommandLineArgs ( $ inputArgs ) ; if ( count ( $ args ) ) { $ this -> scriptName = array_shift ( $ args ) ; } // build help option
 $ helpOpt = false ; if ( $ this -> helpLong ) { $ helpOpt = new Option ( ) ; $ helpOpt -> long ( $ this -> helpLong ) ; } if ( $ this -> helpShort ) { if ( ! $ helpOpt ) { $ helpOpt = new Option ( ) ; } $ helpOpt -> short ( $ this -> helpShort ) ; } if ( $ helpOpt ) { $ this -> configOpts [ Parser :: HELP_OPTION_NAME ] = $ helpOpt ; } try { $ parser = new Parser ( $ this -> configOpts , $ this -> configArgs ) ; $ parser -> parse ( $ args ) ; } catch ( UsageException $ e ) { if ( $ this -> errorHandling ) { $ this -> handleUsageError ( $ e ) ; } else { // re-throw exception
 throw $ e ; } } catch ( ShowHelpException $ e ) { $ this -> showHelp ( ) ; } $ this -> result = $ parser -> getResult ( ) ; }
parse arguments
the first element in the array is treated as script name

@param array $inputArgs
@throws UsageException
parse arguments the first element in the array is treated as script name