Add `wp config add` and `wp config update` commands
- [x] Add new
config addcommand that adds a constant/variable (fails if it already exists) - [x] Add new
config updatecommand that updates or adds a constant/variable (upsert behavior) - [x] Keep
config setcommand for backward compatibility - [x] Add tests for
config addcommand - [x] Add tests for
config updatecommand - [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 --addtoconfig add</issue_title> <issue_description>config set --addis a deviation from our standard syntax. Typically,setandaddare two separate operations (e.g.option setvs.option add, andcache setvs.cache add).It'd be better to abstract
config set --addtoconfig 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 updatecommands for this logic.
config setshould 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.
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!