🌐 AI搜索 & 代理 主页
Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 30, 2025

Include argument descriptions when using --prompt

This PR adds argument descriptions to the interactive prompt output when using the --prompt flag, addressing issue #3121.

Changes Made

Core Implementation (php/WP_CLI/Dispatcher/Subcommand.php):

  • Added get_arg_description() helper method to extract descriptions for all argument types
  • Modified prompt_args() to create a DocParser instance and retrieve descriptions
  • Displays descriptions inline with prompts in parentheses: <name> (The name of the item.):
  • Handles three argument types with custom logic for each:
    • Positional arguments (<name>)
    • Associative parameters (--key=<value>)
    • Flags (--flag)

Comprehensive Tests (features/prompt.feature):

  • Added test scenario with descriptions to verify prompts work correctly
  • Validates that arguments with descriptions are prompted and captured properly
  • Added hardening for array key access to prevent undefined key warnings
  • All existing tests continue to pass without modification

Example Output

Before:

1/3 <name>: 
2/3 --type=<type>: 
3/3 --enabled (Y/n): 

After:

1/3 <name> (The name of the item.): 
2/3 --type=<type> (The type of the item.): 
3/3 --enabled (Whether the item is enabled.) (Y/n): 

Backward Compatibility

✅ Fully backward compatible:

  • Commands without descriptions work exactly as before (descriptions are optional)
  • Descriptions are only displayed when they exist in documentation
  • The (Y/n) indicator for flags is preserved
  • All existing tests pass without modification

Code Quality

  • ✅ No syntax errors
  • ✅ Code review completed: All feedback addressed
  • ✅ Security scan: No vulnerabilities detected
  • ✅ Minimal changes: Only 2 files modified
  • ✅ Well-documented with clear comments

This enhancement significantly improves the user experience for WP-CLI's --prompt feature by providing contextual information about each argument!

Original prompt

This section details on the original issue you should resolve

<issue_title>Include argument descriptions when using --prompt</issue_title>
<issue_description>The --prompt flag is really handy. What would make it even more handy would be if argument descriptions were shown along with the argument names.

For example, here's the current prompt output for wp scaffold theme-tests:

wp scaffold theme-tests --prompt
1/4 [<theme>]: twentyseventeen
2/4 [--dir=<dirname>]:
3/4 [--ci=<provider>]:
4/4 [--force] (Y/n): Y
Success: Created test files.

The purpose and expected value of some arguments are not clear, especially ones which are effectively an ENUM such as --ci. If the argument descriptions were output too, it would be a whole lot clearer and would become very user-friendly.

The main problem is how to display the descriptions which can be quite long and can include things such as the list of possible values.

Ideas welcome.</issue_description>

Comments on the Issue (you are @copilot in this section)

@danielbachhuber Previously https://github.com//issues/3121#issuecomment-241717974 @danielbachhuber > The main problem is how to display the descriptions which can be quite long and can include things such as the list of possible values.

Probably going to close this issue unless there are suggestions for solving this problem.</comment_new>
<comment_new>@danielbachhuber

Perhaps accepting a question mark at each prompt which then displays the expanded info

How would I input ? as a value for the field then?</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 6 commits October 30, 2025 12:21
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Include argument descriptions when using --prompt Add argument descriptions to --prompt interactive prompts Oct 30, 2025
Copilot AI requested a review from swissspidy October 30, 2025 12:39
@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Member

@swissspidy swissspidy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot left some suggestions

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy swissspidy marked this pull request as ready for review October 31, 2025 00:51
@swissspidy swissspidy requested a review from a team as a code owner October 31, 2025 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include argument descriptions when using --prompt

2 participants