config-command icon indicating copy to clipboard operation
config-command copied to clipboard

Add `wp config add` and `wp config update` commands

Open Copilot opened this issue 2 months ago • 1 comments

  • [x] Add new config add command that adds a constant/variable (fails if it already exists)
  • [x] Add new config update command that updates or adds a constant/variable (upsert behavior)
  • [x] Keep config set command for backward compatibility
  • [x] Add tests for config add command
  • [x] Add tests for config update command
  • [x] Update composer.json to register new commands
  • [x] Update class docblock with examples for new commands
  • [x] Address code review feedback
  • [x] Security scan with CodeQL (no issues found)
  • [x] Verify implementation
  • [x] Address PR feedback:
    • Changed WP_DEBUG to WP_CUSTOM_CONSTANT in config-add test (WP_DEBUG exists by default)
    • Fixed assertion in config-update test to expect "Updated" instead of "Added"
    • Aligned equal signs in Config_Command.php
Original prompt

This section details on the original issue you should resolve

<issue_title>Abstract config set --add to config add</issue_title> <issue_description>config set --add is a deviation from our standard syntax. Typically, set and add are two separate operations (e.g. option set vs. option add, and cache set vs. cache add).

It'd be better to abstract config set --add to config add.

We may also consider a config update, which would add the constant if it didn't exist, or update it if it did.</issue_description>

<agent_instructions>Add new wp config add & wp config update commands for this logic.

config set should be kept for backward compatibility.</agent_instructions>

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

@danielbachhuber @wp-cli/committers Does this seem reasonable to you? @schlessera Hehe, I think I started out with `wp config add` & `wp config update`, but then later changed it.
  • Fixes wp-cli/config-command#46

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Nov 02 '25 15:11 Copilot

Codecov Report

:x: Patch coverage is 97.22222% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Config_Command.php 97.22% 2 Missing :warning:

:loudspeaker: Thoughts on this report? Let us know!

codecov[bot] avatar Nov 02 '25 16:11 codecov[bot]