@@ -810,7 +810,7 @@ public function get( $args, $assoc_args ) {
810810 *
811811 * ## OPTIONS
812812 *
813- * <plugin>...
813+ * [ <plugin>...]
814814 * : One or more plugins to uninstall.
815815 *
816816 * [--deactivate]
@@ -820,15 +820,30 @@ public function get( $args, $assoc_args ) {
820820 * : If set, the plugin files will not be deleted. Only the uninstall procedure
821821 * will be run.
822822 *
823+ * [--all]
824+ * : If set, all plugins will be uninstalled.
825+ *
823826 * ## EXAMPLES
824827 *
825828 * $ wp plugin uninstall hello
826829 * Uninstalled and deleted 'hello' plugin.
827830 * Success: Installed 1 of 1 plugins.
828831 */
829832 public function uninstall ( $ args , $ assoc_args = array () ) {
833+
834+ $ all = Utils \get_flag_value ( $ assoc_args , 'all ' , false );
835+
836+ // Check if plugin names of --all is passed.
837+ if ( ! ( $ args = $ this ->check_optional_args_and_all ( $ args , $ all , 'uninstall ' ) ) ) {
838+ return ;
839+ }
840+
830841 $ successes = $ errors = 0 ;
831842 $ plugins = $ this ->fetcher ->get_many ( $ args );
843+ if ( count ( $ plugins ) < count ( $ args ) ) {
844+ $ errors = count ( $ args ) - count ( $ plugins );
845+ }
846+
832847 foreach ( $ plugins as $ plugin ) {
833848 if ( is_plugin_active ( $ plugin ->file ) && ! WP_CLI \Utils \get_flag_value ( $ assoc_args , 'deactivate ' ) ) {
834849 WP_CLI ::warning ( "The ' {$ plugin ->name }' plugin is active. " );
@@ -1082,7 +1097,7 @@ private function get_all_plugins() {
10821097 * @param bool $all All flag.
10831098 * @return array Same as $args if not all, otherwise all slugs.
10841099 */
1085- private function check_optional_args_and_all ( $ args , $ all ) {
1100+ private function check_optional_args_and_all ( $ args , $ all, $ verb = ' install ' ) {
10861101 if ( $ all ) {
10871102 $ args = array_map ( function ( $ file ){
10881103 return Utils \get_plugin_name ( $ file );
@@ -1093,7 +1108,9 @@ private function check_optional_args_and_all( $args, $all ) {
10931108 if ( ! $ all ) {
10941109 WP_CLI ::error ( 'Please specify one or more plugins, or use --all. ' );
10951110 }
1096- WP_CLI ::success ( 'No plugins installed. ' ); // Don't error if --all given for BC.
1111+
1112+ $ past_tense_verb = Utils \past_tense_verb ( $ verb );
1113+ WP_CLI ::success ( "No plugins {$ past_tense_verb }. " ); // Don't error if --all given for BC.
10971114 }
10981115
10991116 return $ args ;
0 commit comments