Skip to content

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

Closed

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

Activity

  1. IgnatGeorgiev commented on Jun 8, 2023

    @IgnatGeorgiev

    Hey, I'm at the WordCamp EU 2023 Contributor Day, want to have a go at this and try to suggest a patch today

  2. IgnatGeorgiev commented on Jun 8, 2023

    @IgnatGeorgiev

    From what I tested, I couldn't seem to reproduce this one anymore

  3. johnbillion commented on Jun 8, 2023

    @johnbillion
    ContributorAuthor

    Thanks for testing @IgnatGeorgiev, which version of WP-CLI are you using?

  4. johnbillion commented on Jun 8, 2023

    @johnbillion
    ContributorAuthor

    I tested this again with WP-CLI 2.8.1 and the issue remains. The --prompt flag does trigger the command output before it runs, but any positional flags that were not provided get missed.

    This can be tested with:

    wp user create --prompt
    
  5. IgnatGeorgiev commented on Jun 8, 2023

    @IgnatGeorgiev

    So far, I've tested with the latest WP-CLI version ( 2.8.1 ) as well as the one reported above ( 2.5.0 ), however I still can't reproduce it properly. I will investigate further, as currently I'm running PHP 8.0.10 and I see the reported issue is reproduced with PHP version 7.4.13.

    If it matters, I'm also testing it with the latest core build, as well

  6. added this to the 2.10.0 milestone on Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo