wp-cli / language-command

Installs, activates, and manages language packs.
MIT License
13 stars 22 forks source link

Support `wp language theme uninstall --all` #124

Closed atoomic closed 11 months ago

atoomic commented 1 year ago

Refs: #122

Add support for '--all' to the Theme uninstall function.

Switch the report output to use a table and support for json.

Related https://github.com/wp-cli/wp-cli/issues/5832

atoomic commented 1 year ago

Install example:

[wpaccount@sandbox-c8-fat ~]$ ~/ww language theme install --all fr_FR
Using cached file '/home/wpaccount/.wp-cli/cache/translation/theme-twentytwentyone-1.0-fr_FR-1647106647.zip'...
Unpacking the update...
Installing the latest version...
Removing the old version of the translation...
Translation updated successfully.
Language 'fr_FR' for 'Twenty Twenty-One' installed.
Using cached file '/home/wpaccount/.wp-cli/cache/translation/theme-twentytwentythree-1.2-fr_FR-1667221284.zip'...
Unpacking the update...
Installing the latest version...
Removing the old version of the translation...
Translation updated successfully.
Language 'fr_FR' for 'Twenty Twenty-Three' installed.
Using cached file '/home/wpaccount/.wp-cli/cache/translation/theme-twentytwentytwo-1.4-fr_FR-1680121959.zip'...
Unpacking the update...
Installing the latest version...
Removing the old version of the translation...
Translation updated successfully.
Language 'fr_FR' for 'Twenty Twenty-Two' installed.
Warning: Language 'fr_FR' not available.
Language 'fr_FR' for 'UniBlock' not installed.
Success: Installed 3 of 4 languages (1 skipped).
+-------------------+--------+---------------+
| name              | locale | status        |
+-------------------+--------+---------------+
| twentytwentyone   | fr_FR  | installed     |
| twentytwentythree | fr_FR  | installed     |
| twentytwentytwo   | fr_FR  | installed     |
| uniblock          | fr_FR  | not available |
+-------------------+--------+---------------+

Uninstall example:

> wp language theme uninstall --all fr_FR
Language 'fr_FR' for 'twentytwentyone' uninstalled.
Language 'fr_FR' for 'twentytwentythree' uninstalled.
Language 'fr_FR' for 'twentytwentytwo' uninstalled.
Language fr_FR not installed.
Success: Language already uninstalled.
+-------------------+--------+---------------+
| name              | locale | status        |
+-------------------+--------+---------------+
| twentytwentyone   | fr_FR  | uninstalled   |
| twentytwentythree | fr_FR  | uninstalled   |
| twentytwentytwo   | fr_FR  | uninstalled   |
| uniblock          | fr_FR  | not installed |
+-------------------+--------+---------------+

then on a second run

> wp language theme uninstall --all fr_FR
Language fr_FR not installed.
Language fr_FR not installed.
Language fr_FR not installed.
Language fr_FR not installed.
Success: Language already uninstalled.
+-------------------+--------+---------------+
| name              | locale | status        |
+-------------------+--------+---------------+
| twentytwentyone   | fr_FR  | not installed |
| twentytwentythree | fr_FR  | not installed |
| twentytwentytwo   | fr_FR  | not installed |
| uniblock          | fr_FR  | not installed |
+-------------------+--------+---------------+
atoomic commented 1 year ago

note: need to adjust and add some unit tests the uninstall is now using a table output

atoomic commented 1 year ago

fixed phpcs

atoomic commented 1 year ago

fixed and added some tests, ready for review round 2