wp-cli / entity-command

Manage WordPress comments, menus, options, posts, sites, terms, and users.
MIT License
100 stars 90 forks source link

Add a `wp user exists` subcommand #484

Closed kkmuffme closed 7 months ago

kkmuffme commented 7 months ago

Feature Request

Describe your use case and the problem you are facing

Using wp user get writes to stderr when the user doesn't exist, which makes it porcelain, since it needs to be parsed and processed to be able to distinguish between user doesn't exist and unrelated errors.

Describe the solution you'd like

There should be a command like wp user exists to check whether a user exists or not, returning 0 on success, 1 if it doesn't exist and not write anything to stderr in that case. Like wp plugin is-active which does this for plugins.

swissspidy commented 7 months ago

Sounds reasonable 👍 There are already similar commands such as wp post exists and wp comment exists.

We could consider adding an exists command for all entities that have a get command already, for consistency.