Determine if an argument has been defined on the command line and get the value.

@param string $name
@param array $argv

@return bool
557268
public function get_arg($name, array $argv = null)
    {
        if ($this->climate->arguments->defined($name, $argv)) {
            return $this->climate->arguments->get($name);
        }
        return false;
    }
98010
protected function setArgumentValue($argv, $argument, $key, $value)
    {
        // Arguments are given the value true if they only need to
        // be defined on the command line to be set.
        if ($argument->noValue()) {
            $argument->setValue(true);
            return $argv;
        }

        if (is_null($value)) {
            if (count($argv) === 0) {
                return $argv;
            }

            // If the value wasn't previously defined in "key=value"
            // format then define it from the next command argument.
            $nextArgvValue = $argv[$key + 1];
            if ($this->isValidArgumentValue($nextArgvValue)) {
                $argument->setValue($nextArgvValue);
                unset($argv[$key + 1]);
                return $argv;
            }
        }

        $argument->setValue($value);

        return $argv;
    }
279497
public function __callProtectedMethod($name, $arguments = [])
    {
        try {
            $method = $this->__reflection()->getMethod($name);
        }
        catch(\Exception $e) {
            return next::caller();
        }

        $method->setAccessible(true);
        $result =  $method->invokeArgs($this, $arguments);
        $method->setAccessible(false);

        return $result;
    }
865046
def is_argument(self, name):
        
        if name == self.vararg:
            return True
        if name == self.kwarg:
            return True
        return (
            self.find_argname(name, True)[1] is not None
            or self.kwonlyargs
            and _find_arg(name, self.kwonlyargs, True)[1] is not None
        )
709562
public function parse(array $argv): self
    {
        $this->_normalizer = new Normalizer;

        \array_shift($argv);

        $argv    = $this->_normalizer->normalizeArgs($argv);
        $count   = \count($argv);
        $literal = false;

        for ($i = 0; $i < $count; $i++) {
            list($arg, $nextArg) = [$argv[$i], $argv[$i + 1] ?? null];

            if ($arg === '--') {
                $literal = true;
            } elseif ($arg[0] !== '-' || $literal) {
                $this->parseArgs($arg);
            } else {
                $i += (int) $this->parseOptions($arg, $nextArg);
            }
        }

        $this->validate();

        return $this;
    }
191090
public function run(array $argv = null)
    {
        try {
            if ($argv === null) {
                $argv = isset($_SERVER['argv']) ? array_slice($_SERVER['argv'], 1) : [];
            }

            list($args, $options) = Input::parse($argv);

            $command = count($args) ? array_shift($args) : 'help';

            if (!isset($this->commands[$command])) {
                throw new \InvalidArgumentException("Command '$command' does not exist");
            }

            isset($options['no-ansi']) && Colour::setNoAnsi();
            if (isset($options['h']) || isset($options['help'])) {
                $help = new Help($this);
                $help->execute([$command]);
                exit(0);
            }

            $command = explode('::', $this->commands[$command]);

            return call_user_func_array([new $command[0]($this), isset($command[1]) ? $command[1] : 'execute'], [$args, $options]);
        } catch (\Exception $e) {
            Output::writeException($e);
            exit(1);
        }
    }
846028
public function execute($name, $args)
	{
	    if (!$this->__sock) {
	        return null;
	    }
	    
	    $args = (array) $args;
	    if(in_array($name, static::$keyCommands)) {
	        if ($this->options['prefix'] && strpos($args[0], $this->options['prefix']) === false) {
	            $args[0] = $this->options['prefix'] . $args[0];
	        }
	    }
	    
	    /* Build the Redis unified protocol command */
	    array_unshift($args, strtoupper($name));
	    $command = sprintf('*%d%s%s%s', count($args), CRLF, implode(array_map(array($this, 'formatArgument'), $args), CRLF), CRLF);
	    
	    /* Open a Redis connection and execute the command */
	    for ($written = 0; $written < strlen($command); $written += $fwrite) {
	        $fwrite = fwrite($this->__sock, substr($command, $written));
	        if ($fwrite === FALSE) {
	            throw new Exception('Failed to write entire command to stream');
	        }
	    }
	    
	    /* Parse the response based on the reply identifier */
	    $reply = trim(fgets($this->__sock, 512));
	    switch (substr($reply, 0, 1)) {
	        /* Error reply */
	        case '-':
	            throw new RedisException(substr(trim($reply), 4));
	            break;
	            /* Inline reply */
	        case '+':
	            $response = substr(trim($reply), 1);
	            break;
	            /* Bulk reply */
	        case '$':
	            $response = null;
	            if ($reply == '$-1') {
	                break;
	            }
	            $read = 0;
	            $size = substr($reply, 1);
	            do {
	                $block_size = ($size - $read) > 1024 ? 1024 : ($size - $read);
	                $response .= fread($this->__sock, $block_size);
	                $read += $block_size;
	            } while ($read < $size);
	            fread($this->__sock, 2); /* discard crlf */
	            break;
	            /* Multi-bulk reply */
	        case '*':
	            $count = substr($reply, 1);
	            if ($count == '-1') {
	                return null;
	            }
	            $response = array();
	            for ($i = 0; $i < $count; $i++) {
	                $bulk_head = trim(fgets($this->__sock, 512));
	                $size = substr($bulk_head, 1);
	                if ($size == '-1') {
	                    $response[] = null;
	                }
	                else {
	                    $read = 0;
	                    $block = "";
	                    do {
	                        $block_size = ($size - $read) > 1024 ? 1024 : ($size - $read);
	                        $block .= fread($this->__sock, $block_size);
	                        $read += $block_size;
	                    } while ($read < $size);
	                    fread($this->__sock, 2); /* discard crlf */
	                    $response[] = $block;
	                }
	            }
	            break;
	            /* Integer reply */
	        case ':':
	            $response = intval(substr(trim($reply), 1));
	            break;
	        default:
	            throw new RedisException("invalid server response: {$reply}");
	            break;
	    }
	    /* Party on */
	    return $response;
	}
588964
public static function exists($name)
    {
        if(is_integer($name))
        {
            return isset($_SERVER['argv'][$name]);
        }
        else
        {
            return isset(static::$cliArgs[$name]);
        }
    }
1241349
public function hasArgument($name)
    {
        $arguments = is_numeric($name) ? array_values($this->arguments) : $this->arguments;

        return isset($arguments[$name]);
    }
49786
public function hasArgument($name)
    {
        $offset = array_search($name, $this->argNames, true);
        if ($offset === false) {
            return false;
        }

        return isset($this->args[$offset]);
    }
1060727
public static function call_if_exists($name, $arguments = []) {
		if (self::exists($name)) {
			$application = Application::get();
			$classname = 'Hook_' . ucfirst($application->name);
			call_user_func_array([$classname, $name], $arguments);
		}
	}
101041
public function handler($name, Args $args)
    {
        if (
            !$this->checkLevel($args->get('level')) ||
            !$this->checkSource($args->get('source'))
        ) {
            return;
        }

        switch ($name) {
            /*
            case ':log:':
                $this->log($args);
                break; // case 'log'

            */
            case ':onAddHandler:':
                $args->set('message', sprintf(
                    "Adding handler %s, %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    ),
                    $args->get('added', false)
                        ? "successfully" :
                        "failed (duplicate handler)"
                ));
                break; // case ':onAddHandler:'

            case ':onEventStart:':
                $args->set('message', sprintf(
                    "{ '%s' (%s), args [%s]",
                    $args->get('name'),
                    $args->get('uid'),
                    implode(', ', array_keys($args->get()))
                ));
                break; // case ':onEventStart:'

            case ':onHandlerFound:':
                $args->set('message', sprintf(
                    "Handler %s found",
                    $this->handlerToString($args->get('handler'))
                ));
                break; // case ':onAddHandler:'

            case ':onEventEnd:':
                $args->set('message', sprintf(
                    "} '%s' (%s), args [%s]",
                    $args->get('name'),
                    $args->get('uid'),
                    implode(', ', array_keys($args->get()))
                ));
                break; // case ':onEventEnd:'

            case ':onDropHandlers:':
                $args->set('message', sprintf(
                    "Dropping handler %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    )
                ));
                break; // case ':onDropHandlers:'

            case ':onDisableHandler:':
                $args->set('message', sprintf(
                    "Disabling handler %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    )
                ));
                break; // case ':onDropHandlers:'

            case ':onEnableHandler:':
                $args->set('message', sprintf(
                    "Enabling handler %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    )
                ));
                break; // case ':onDropHandlers:'
        }
        $this->log($args);
    }
1303233
public function get(Name $name)
    {
        if (!$this->arguments->contains((string) $name)) {
            throw new ArgumentNotDefined((string) $name);
        }

        if (!$this->values->contains((string) $name)) {
            throw new ArgumentNotProvided($this->arguments->get((string) $name));
        }

        return $this->values->get((string) $name);
    }
564209
public function get_args($name){
    if ( $this->checked ){
      $cmd_name = str_replace('_', '-', $name);
      return isset($this->commands[$cmd_name], $this->commands[$cmd_name]['args']) ? $this->commands[$cmd_name]['args'] : [];
    }
  }
92460
public function execByName(string $name, array $keys = [], array $argv = [])
    {
        return $this->handle->evalSha($name, array_merge($keys, $argv), count($keys));
    }
1313462
protected function parseArg(array $argv, $argNum)
    {
        $arg = $argv[$argNum];
        $argsParsed = 1;
        if (self::isOption($arg)) {
            // This is an option
            $argsParsed = $this->parseOption($argv, $argNum);
        } elseif (self::isArgumentSeparator($arg)) {
            // Its the argument separator - every following argument
            // is an actual argument, not an option, regardless of dashes
            $slice = array_slice($argv, $argNum + 1);
            $this->arguments = array_merge($this->arguments, $slice);
            $argsParsed += count($slice);
        } else {
            // Its just an argument because it is not following an option
            $this->arguments[] = $arg;
        }

        return $argsParsed;
    }
1080357
public function findArgument($name) {
        foreach ($this->getArguments() as $argument) {
            if ($argument->getName() === $name) {
                return $argument;
            }
        }

        throw new ArgumentNotFoundException(s(
            'Argument "%s" does not exist.',
            $name
        ));
    }