Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 30, 2025

Summary: Show default values for parameters and positional arguments when using --prompt

Successfully implemented default value display for WP-CLI's --prompt flag.

Problem

When using --prompt, no defaults were shown for parameters or positional arguments, making it unclear what value would be used.

Solution Implemented

Display defaults for parameters and positional arguments

  • Parameters show: --format=<format> [table]
  • Positional args show: <name> [World]
  • Empty input applies the default value from PHPdoc

Maintain backward compatibility

  • Flags continue to show (Y/n) notation (unchanged)
  • Empty input for flags means NOT set (original behavior)
  • Only "Y"/"y" sets flags to true

Changes Made

Core Logic (php/WP_CLI/Dispatcher/Subcommand.php)

  • Added DocParser to retrieve default values from PHPdoc YAML
  • Display defaults in brackets [default] for parameters and args
  • Apply defaults on empty input for non-flag arguments
  • Fixed code formatting (equals sign alignment)

Tests (features/prompt.feature)

  • Added 3 test scenarios for new functionality
  • Tests verify command summary output and actual results
  • Follow existing test patterns

Example Output

Parameters with defaults:

$ wp post list --prompt
1/2 [--format=<format>] [table]: [Enter]
→ wp post list --format='table'
→ Result uses 'table' format

Positional args with defaults:

$ wp greet --prompt
1/1 <name> [World]: [Enter]
→ wp greet 'World'
→ Hello World

Flags (unchanged):

1/3 [--force] (Y/n): [Enter]
→ Flag NOT set

1/3 [--force] (Y/n): Y
→ wp command --force
→ Flag set to true

Testing

  • 3 new test scenarios cover the feature
  • Tests check command summary and actual output
  • Original behavior for flags maintained
  • Ready for CI validation

Status: ✅ Ready for review

Original prompt

This section details on the original issue you should resolve

<issue_title>Show default values for arguments when using --prompt</issue_title>
<issue_description>When using the --prompt flag, the default value for each argument is not clear. For example:

8/8 [--force] (Y/n):

It's not clear whether the default value here is Y or n.

How can we make it clearer what the default value of an argument is?

Somewhat related: #4088</issue_description>

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

@schlessera Isn't this what the uppercase letter shows?

✨ 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 changed the title [WIP] Clarify default values for arguments using --prompt Show default values in prompt notation and apply on empty input Oct 30, 2025
Copilot AI requested a review from swissspidy October 30, 2025 12:31
@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!

@swissspidy

This comment was marked as resolved.

This comment was marked as resolved.

Copilot AI changed the title Show default values in prompt notation and apply on empty input Show default values for parameters and positional arguments when using --prompt Oct 30, 2025
@swissspidy

This comment was marked as resolved.

This comment was marked as resolved.

@swissspidy swissspidy marked this pull request as ready for review October 30, 2025 21:34
@swissspidy swissspidy requested a review from a team as a code owner October 30, 2025 21:34
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.

Show default values for arguments when using --prompt

2 participants