wp-cli/wp-cli — pull request #600 by drrobotnik (2013-07-17 04:23:43+00:00)
Title: add user prompts request_input and request_options

I've wanted an interactive console for wp-cli for awhile and I've seen a few comments that mention it'd be desirable, so here's my approach.

This would make it easier to prompt users when they've left out required elements or provide the user with a list of options to choose from.

Here's how it could be used in wp scaffold_s:

if( empty( $data['theme_name'] ) ){
$result = WP_CLI::request_input( 'Theme Name is required.' );
$data['theme_name'] = sanitize_text_field($result);
}

And use case for a series of controlled options.

$result = WP_CLI::request_options( 'Favorite forgotten Disney character?', array('fox','hound','tramp') );
WP_CLI::success("Valid Response: ".$result);