Return the flag value or, if it’s not set, the $default value.
Usage
WP_CLI\Utils\get_flag_value( $assoc_args, $flag, $default = null )
$assoc_args (array<string|int,string|bool>) Arguments array.
$flag (string|int) Flag to get the value.
$default (string|bool|int|null) Default value for the flag. Default: NULL.
@return (string|bool|int|null)
$flag (string|int) Flag to get the value.
$default (string|bool|int|null) Default value for the flag. Default: NULL.
@return (string|bool|int|null)
Notes
Because flags can be negated (e.g. –no-quiet to negate –quiet), this
function provides a safer alternative to using
isset( $assoc_args['quiet'] ) or similar.
Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request.
Related
- WP_CLI\Utils\launch_editor_for_input() – Launch system’s $EDITOR for the user to edit some text.
- WP_CLI\Utils\report_batch_operation_results() – Report the results of the same operation against multiple resources.
- WP_CLI\Utils\parse_str_to_argv() – Parse a string of command line arguments into an $argv-esqe variable.
- WP_CLI::confirm() – Ask for confirmation before running a destructive operation.
- WP_CLI::read_value() – Read a value, from various formats.
- WP_CLI::has_config() – Confirm that a global configuration parameter does exist.
- WP_CLI::get_config() – Get values of global configuration parameters.