GetOptionKit\ContinuousOptionParser::getCurrentArgument PHP Method

getCurrentArgument() public method

Return the current argument that the index pointed to.
public getCurrentArgument ( ) : string
return string
    public function getCurrentArgument()
    {
        return $this->argv[$this->index];
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @param array $argv Array of arguments passed to script
  * @example
  * ```php
  * $binary = new Bin([
  *     __FILE__,
  *     '--help'
  * ]);
  *
  * return $binary->invoke();
  * ```
  */
 public function __construct($argv)
 {
     $parser = new ContinuousOptionParser(static::getArgumentSpecifications());
     $subCommandSpecs = static::getSubCommandsSpecs();
     $subCommands = array_keys((array) $subCommandSpecs);
     //Parse specification arguments from given arguments
     $this->arguments = $parser->parse($argv);
     $arguments = [];
     $subCommandOptions = new \stdClass();
     while (!$parser->isEnd()) {
         if (@$subCommands[0] && $parser->getCurrentArgument() == $subCommands[0]) {
             $parser->advance();
             $subCommand = array_shift($subCommands);
             $parser->setSpecs($subCommandSpecs->{$subCommand});
             $subCommandOptions->{$subCommand} = $parser->continueParse();
         } else {
             $arguments[] = $parser->advance();
         }
     }
     $this->subCommandOptions = $subCommandOptions;
 }
All Usage Examples Of GetOptionKit\ContinuousOptionParser::getCurrentArgument