Feature: Prompt user for input Scenario: Flag prompt should be case insensitive Given an empty directory And a cmd.php file: """ * : An positional arg. * * [--flag1=] * : An optional flag * * [--flag2=] * : An optional flag * * @when before_wp_load */ WP_CLI::add_command( 'foobar', function( $_, $assoc_args ) { WP_CLI::line( 'arg: ' . $_[0] ); WP_CLI::line( 'flag1: ' . $assoc_args['flag1'] ); } ); """ And a wp-cli.yml file: """ require: - command-foobar.php """ When I run `echo 'bar' | wp foobar foo --prompt=flag1` Then the return code should be 0 And STDERR should be empty And STDOUT should contain: """ arg: foo """ And STDOUT should contain: """ flag1: bar """ When I run `wp foobar foo --prompt --help` Then STDOUT should contain: """ wp foobar """ And STDERR should be empty Scenario: Prompt should skip arguments that are already provided Given an empty directory And a cmd.php file: """ * : A positional arg. * * * : A positional arg. * * [--flag1=] * : A flag. * * [--flag2=] * : A flag. * * [--flag3=] * : A flag. * * @when before_wp_load */ WP_CLI::add_command( 'test-prompt', function( $args, $assoc_args ) { WP_CLI::line( 'arg1: ' . $args[0] ); WP_CLI::line( 'arg2: ' . $args[1] ); WP_CLI::line( 'flag1: ' . $assoc_args['flag1'] ); WP_CLI::line( 'flag2: ' . $assoc_args['flag2'] ); WP_CLI::line( 'flag3: ' . $assoc_args['flag3'] ); } ); """ And a value-file file: """ positional2 value2 """ And a wp-cli.yml file: """ require: - cmd.php """ When I run `wp test-prompt positional1 --flag1=value1 --flag3=value3 --prompt < value-file` Then the return code should be 0 And STDERR should be empty And STDOUT should contain: """ arg1: positional1 """ And STDOUT should contain: """ arg2: positional2 """ And STDOUT should contain: """ flag1: value1 """ And STDOUT should contain: """ flag2: value2 """ And STDOUT should contain: """ flag3: value3 """ Scenario: Prompt should show full command after inputs Given a WP installation And a value-file file: """ post_type post post_title,post_name,post_status csv """ When I run `wp post create --post_title='Publish post' --post_content='Publish post content' --post_status='publish'` Then STDOUT should not be empty When I run `wp post create --post_title='Publish post 2' --post_content='Publish post content' --post_status='publish'` Then STDOUT should not be empty When I run `wp post list --prompt < value-file` Then STDOUT should contain: """ wp post list --post_type='post' --fields='post_title,post_name,post_status' --format='csv' """ And STDOUT should contain: """ post_title,post_name,post_status """ And STDOUT should contain: """ "Publish post 2",publish-post-2,publish """ And STDOUT should contain: """ "Publish post",publish-post,publish """ And STDOUT should contain: """ "Hello world!",hello-world,publish """ Scenario: Prompt should show positional arguments Given a WP installation And a value-file file: """ category General general """ When I run `wp term create --prompt < value-file` Then STDOUT should contain: """ wp term create 'category' 'General' --slug='general' """ And STDOUT should contain: """ Created category """