Given supplied arguments, find a contained
subcommand

@param array $args
@return \WP_CLI\Dispatcher\Subcommand|false
478
public function find_subcommand( &$args ) {
		$name = array_shift( $args );

		$subcommands = $this->get_subcommands();

		if ( ! isset( $subcommands[ $name ] ) ) {
			$aliases = self::get_aliases( $subcommands );

			if ( isset( $aliases[ $name ] ) ) {
				$name = $aliases[ $name ];
			}
		}

		if ( ! isset( $subcommands[ $name ] ) ) {
			return false;
		}

		return $subcommands[ $name ];
	}
453465
protected function composeCommand($args): string
    {
        $command = $this->getBinary();

        if (\is_array($args)) {
            $args = implode(' ', $args);
        }

        // Only append args if we have some
        $command .= $args !== '' ? ' ' . $args : '';

        return $command;
    }
694289
public function getArguments( $arguments = array() )
    {
        $_results = array(
            'original' => $arguments,
            'rebuilt'  => array(),
            'options'  => array(),
        );

        //	Our return options array...
        $_options = array();

        //	Rebuild args...
        for ( $_i = 0, $_count = count( $arguments ); $_i < $_count; $_i++ )
        {
            $_argument = $arguments[$_i];
            $_value = trim( substr( $_argument, 0, strpos( $_argument, '=' ) ) );

            if ( $_value && $_value[0] == '-' && $_value[1] == '-' )
            {
                $_options[substr( $_value, 2 )] = str_replace( $_value . '=', '', $_argument );
            }
            elseif ( $_value && $_value[0] == '-' )
            {
                $_options[substr( $_value, 1 )] = str_replace( $_value . '=', '', $_argument );
            }
            else
            {
                $_results['rebuilt'][] = $arguments[$_i];
            }
        }

        $_results['options'] = $_options;

        //	Return the processed results...
        return $_results;
    }
1242030
protected function parseArgs(string $arg)
    {
        if ($this->_lastVariadic) {
            return $this->set($this->_lastVariadic, $arg, true);
        }

        if (!$argument = \reset($this->_arguments)) {
            return $this->set(null, $arg);
        }

        $this->setValue($argument, $arg);

        // Otherwise we will always collect same arguments again!
        if (!$argument->variadic()) {
            \array_shift($this->_arguments);
        }
    }
1095227
private function cmdReset($args)
    {
        $cmd = new ResetCommand($this->cwd);

        return $cmd->run(array_slice($args, 1));
    }
1305549
public function handle(array $args)
    {
        $this->filter->add('themosis_admin_global', function ($data) use ($args) {
            if (! isset($data['metabox'])) {
                $data['metabox'] = [$this->id];
            } elseif (isset($data['metabox'])) {
                $data['metabox'][] = $this->id;
            }

            /*
             * Provides WP_Post data.
             */
            $data['post'] = $args['post'];

            return $data;
        });
    }
869529
public function filter_arguments( $arg ) {
		$patterns = array(
			'url=', 'path=', 'user=', 'skip-plugins=?', 'skip-themes=?',
			'require=', 'no-color', 'color', 'prompt', 'allow-root',
		);

		foreach ( $patterns as $pattern ) {
			if ( preg_match( "~^--{$pattern}~i", $arg ) ) {
				return false;
			}
		}

		return true;
	}
1128137
public static function escape(array $args): string
  {
    $command = '';
    foreach ($args as $arg)
    {
      if ($command!='') $command .= ' ';
      $command .= escapeshellarg($arg);
    }

    return $command;
  }
1262910
public function url( array $args = [] ) {
		$url = $this->siteurl;
		if ( $args ) {
			$url = add_query_arg( $args, $url );
		}

		return $url;
	}
1262566
public function formatArgs($args)
    {
        // The first argument is always the file
        unset($args[0]);

        if (isset($args[1])) {
            $command = explode(':', $args[1]);
            unset($args[1]);
        } else {
            // No Command Specified.
            return array();
        }

        try {

            $action = (isset($command[1]) ? $command[1] : 'main');
            $cmd = $this->library->find($command[0].':'.$action);
            $task = get_class($cmd);

            return array(
                'task'      => $task,
                'action'    => $action,
                'params'    => $args
            );

        } catch (\Exception $e) {

            // No Command FOUND
            return array();
        }
    }
365681
public function command($args)
    {
        // Throw if no arguments provided and args less than 2
        if (empty($args) || count($args) < 2) {
            throw new RuntimeException("Invalid argument count");
        }

        $secondArg = $args[1];

        // Output the second argument
        return $secondArg;

    }
162002
public function find($includeArgs = true)
    {
        $args = $this->findArguments();
        $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';

        // HHVM support
        if (defined('HHVM_VERSION')) {
            return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
        }

        // PHP_BINARY return the current sapi executable
        if (PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server', 'phpdbg')) && is_file(PHP_BINARY)) {
            return PHP_BINARY.$args;
        }

        if ($php = getenv('PHP_PATH')) {
            if (!is_executable($php)) {
                return false;
            }

            return $php;
        }

        if ($php = getenv('PHP_PEAR_PHP_BIN')) {
            if (is_executable($php)) {
                return $php;
            }
        }

        $dirs = array(PHP_BINDIR);
        if ('\\' === DIRECTORY_SEPARATOR) {
            $dirs[] = 'C:\xampp\php\\';
        }

        return $this->executableFinder->find('php', false, $dirs);
    }
1147960
public function run(array $args)
    {
        $command = 'help';

        if (isset($args[1])) {
            $command = $args[1];
        }

        //cradle author/vendor action
        if (strpos($command, '/') !== false) {
            $command = 'package';
            array_splice($args, 1, 0, array($command));
        }

        //if command is package
        if ($command === 'package'
            && (//and no package was defined
                !isset($args[2])
                || strpos($args[2], '/') === false
            )
        ) {
            $command = 'event';
            array_splice($args, 1, 0, ['event']);
        }

        $class = sprintf(self::COMMAND_CLASS, ucwords($command));

        if (!class_exists($class)) {
            //by default it's an event
            $class = sprintf(self::COMMAND_CLASS, 'Event');
            array_splice($args, 1, 0, array('event'));
        }

        array_shift($args);
        $runner = new $class($this->cwd);

        $results = $runner->run($args);

        self::output(PHP_EOL);

        return $results;
    }
351886
protected function getEnvironmentArgument(array $args)
	{
		foreach ($args as $k => $v)
		{
			if (substr($v, 0, strlen('--env')) == '--env')
			{
				return $v;
			}
		}

		return null;
	}
518361
public static function findCommandValue($args) {
		$args = explode("|",$args);
		foreach ($args as $arg) {
			if (isset(self::$options[$arg])) {
				return self::$options[$arg];
			}
		}
		return false;
	}
1183152
public function get( $args, $assoc_args ) {
		list( $alias ) = $args;

		$aliases = WP_CLI::get_runner()->aliases;

		if ( empty( $aliases[ $alias ] ) ) {
			WP_CLI::error( "No alias found with key '{$alias}'." );
		}

		foreach ( $aliases[ $alias ] as $key => $value ) {
			WP_CLI::log( "{$key}: {$value}" );
		}
	}
507044
public function command($args)
    {
        // Access items in container
        $settings = $this->container->get('settings');
        
        // Throw if no arguments provided
        if (empty($args)) {
            throw new RuntimeException("No arguments passed to command");
        }

        $firstArg = $args[0];

        // Output the first argument
        return $firstArg;
    }