Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding --dry-run as an option for destructive wp post and wp user commands #89

Closed
davemac opened this issue Mar 15, 2018 · 6 comments

Comments

@davemac
Copy link

davemac commented Mar 15, 2018

When deleting post and user data/meta, it would be handy to have a --dry-run option to see what the results of running that command may be.

@danielbachhuber
Copy link
Member

Hi @davemac,

Thanks for the suggestion. Can you explain in greater detail how this might work? What's the problem you're trying to solve?

@davemac
Copy link
Author

davemac commented Mar 19, 2018

@danielbachhuber I recently ran the following on a staging site (deletes all thumbnail images from a post type):

wp post list --post_type=dmc-sief-project --fields=ID --format=csv | xargs -I % wp post meta delete % _thumbnail_id
If there was a --dry-run option for wp post meta delete that worked in a similar way to the --dry-run option for wp search-replace then I could see a list of posts/meta that will be affected before running the actual (destructive) command.

The --dry-run option would be useful for any command that potentially deletes post or user meta.

Of course, this would not substitute for backing up the database.

@danielbachhuber
Copy link
Member

then I could see a list of posts/meta that will be affected before running the actual (destructive) command.

Just to tease out the idea further, how would this be helpful? Can't you already do this with xargs -I % wp post meta get % _thumbnail_id

@davemac
Copy link
Author

davemac commented Mar 20, 2018

You are correct, and in fact I ran that command before doing the delete. That's when I thought maybe just adding a --dry-run to the delete would be a nice option and make dry runs more accessible to users.

If done globally on destructive wp post and wp user commands, it would bring consistency with wp search-replace - but I do take your point.

@danielbachhuber
Copy link
Member

Makes sense, thanks @davemac. I think implementing a --dry-run flag as you describe would be non-trivial. Given there's a reasonable alternative, let's defer to the alternative for now.

@bjmgeek
Copy link

bjmgeek commented Oct 6, 2023

I think this would be useful for lots of different commands. For instance, wp option delete or wp db drop could provide a dry-run option to show what would be done, without actually doing anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants