WP_CLI\Dispatcher
Subcommand::prompt
Wrapper for CLI Tools' prompt() method.
Method of the class: Subcommand{}
No Hooks.
Returns
String|false.
Usage
// private - for code of main (parent) class only $result = $this->prompt( $question, $default );
- $question(string) (required)
- .
- $default(string) (required)
- .
Subcommand::prompt() Subcommand::prompt code WP-CLI 2.13.0-alpha
private function prompt( $question, $default ) {
$question .= ': ';
if ( function_exists( 'readline' ) ) {
return readline( $question );
}
echo $question;
$ret = stream_get_line( STDIN, 1024, "\n" );
if ( Utils\is_windows() && "\r" === substr( $ret, -1 ) ) {
$ret = substr( $ret, 0, -1 );
}
return $ret;
}