Skip to content

--prompt output does not include missing positional parameters #5768

@johnbillion

Description

@johnbillion

Bug Report

Describe the current, buggy behavior

When running a command with the --prompt flag, the command that is subsequently run gets output to the terminal. This is useful for re-running the command or for learning commands interactively.

When --prompt is used but not all required positional parameters are included, the subsequent output misses those parameters, making the command invalid if the user re-uses it.

Describe how other contributors can replicate this bug

  • Run wp user create --prompt
  • Fill in the details
  • Observe the command that gets output before it's executed is missing the <user-login> and <user-email> positional parameters

Example:

wp user create --prompt
1/15 <user-login>: john@example.com
2/15 <user-email>: john@example.com
3/15 [--role=<role>]: administrator
4/15 [--user_pass=<password>]: password
5/15 [--user_registered=<yyyy-mm-dd-hh-ii-ss>]:
6/15 [--display_name=<name>]: John
7/15 [--user_nicename=<nice_name>]:
8/15 [--user_url=<url>]:
9/15 [--nickname=<nickname>]:
10/15 [--first_name=<first_name>]:
11/15 [--last_name=<last_name>]:
12/15 [--description=<description>]:
13/15 [--rich_editing=<rich_editing>]:
14/15 [--send-email] (Y/n): n
15/15 [--porcelain] (Y/n):
wp user create --role='administrator' --user_pass='password' --display_name='John'
Error: Usernames can only contain lowercase letters (a-z) and numbers.

Note the wp user create ... output is missing its two required positional parameters.

Describe what you expect as the correct outcome

The actual command that was run is:

wp user create john@example.com john@example.com --role='administrator' --user_pass='password' --display_name='John'

This should be accurately shown in the output.

Let us know what environment you are running this on

OS:	Linux 5.10.104-linuxkit #1 SMP PREEMPT Thu Mar 17 17:05:54 UTC 2022 aarch64
Shell:
PHP binary:	/usr/local/bin/php
PHP version:	7.4.13
php.ini used:	/usr/local/etc/php/php.ini
MySQL binary:	/usr/bin/mysql
MySQL version:	mysql  Ver 15.1 Distrib 10.4.19-MariaDB, for Linux (aarch64) using readline 5.1
SQL modes:
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/usr/src/app
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:	/usr/src/app/wp-cli.yml
WP-CLI version:	2.5.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions