WP_CLI::get_value_from_arg_or_stdin
Read value from a positional argument or from STDIN.
Метод класса: WP_CLI{}
Хуков нет.
Возвращает
Строку.
Использование
$result = WP_CLI::get_value_from_arg_or_stdin( $args, $index );
- $args(массив) (обязательный)
- The list of positional arguments.
- $index(int) (обязательный)
- At which position to check for the value.
Код WP_CLI::get_value_from_arg_or_stdin() WP CLI::get value from arg or stdin WP-CLI 2.13.0-alpha
public static function get_value_from_arg_or_stdin( $args, $index ) {
if ( isset( $args[ $index ] ) ) {
$raw_value = $args[ $index ];
} else {
// We don't use file_get_contents() here because it doesn't handle
// Ctrl-D properly, when typing in the value interactively.
$raw_value = '';
$line = fgets( STDIN );
while ( false !== $line ) {
$raw_value .= $line;
$line = fgets( STDIN );
}
}
return $raw_value;
}