PHP Class VersionPress\Cli\VPCommandUtils

Datei anzeigen Open project: versionpress/versionpress Class Usage Examples

Public Methods

Method Description
cliQuestion ( string $question, array $values, array $assoc_args = [] ) : string Asks user a question, offers an array of values and returns what he/she entered. The first value in the $values array is the default one, used if the user just ENTERs the question or types in some random value. The $assoc_args array may be given as the third parameter, in which case it behaves like in WP_CLI::confirm() and will return 'y' is such value is in $values, or the default value.
exec ( string $command, string | null $cwd = null ) : Process Executes a command, optionally in a specified working directory.
fixTypeOfValue ( string $value ) : boolean | integer | float | string WP-CLI args are always strings. This method restores the original type.
runWpCliCommand ( $command, $subcommand, $args = [], $cwd = null )
warning ( $message )

Method Details

cliQuestion() public static method

Inspired by WP_CLI::confirm() that can only do "yes" / "no" and cannot really return "no" (it just exits in such case).
public static cliQuestion ( string $question, array $values, array $assoc_args = [] ) : string
$question string
$values array e.g. ["y", "n"] or ["1", "2", "3"]
$assoc_args array If $assoc_args contain 'yes' and $values contain 'y', it will be automatically answered. (Similar behavior to WP_CLI::confirm().)
return string The answer

exec() public static method

Executes a command, optionally in a specified working directory.
public static exec ( string $command, string | null $cwd = null ) : Process
$command string
$cwd string | null
return VersionPress\Utils\Process

fixTypeOfValue() public static method

WP-CLI args are always strings. This method restores the original type.
public static fixTypeOfValue ( string $value ) : boolean | integer | float | string
$value string
return boolean | integer | float | string

runWpCliCommand() public static method

public static runWpCliCommand ( $command, $subcommand, $args = [], $cwd = null )

warning() public static method

public static warning ( $message )