diggy / polylang-cli

WP-CLI community package of Polylang commands
https://github.com/diggy/polylang-cli
MIT License
34 stars 19 forks source link

FEATURE: test language existence #53

Closed gbouteiller closed 7 years ago

gbouteiller commented 7 years ago

Hello @diggy, As I told you in a different post, I use your package with Ansible. The problem that I encounter is that If I run wp pll lang delete --all or wp pll lang list --format=count, I get an error. In my ansible task, I would like to delete languages if they exist before adding other languages. So would it be possible to have a flag to perform a delete even if there are no languages or at least return 0 instead of an error if I try to list the languages with format=count ?

diggy commented 7 years ago

Unfortunately I'm not familiar with Ansible, are you sure there is no way to try/catch the exit(1) emitted by WP_CLI::error()?

diggy commented 7 years ago

What about using wp term list language --format=count?

gbouteiller commented 7 years ago

Yes there is and I can force the next tasks even if there is an error. But don't you think that it is consistent to have 0 on stdout when requesting wp pll lang list --format =count instead of an error? As it should be consistent with wp term list language --format=count ?

diggy commented 7 years ago

absolutely!