@@ -259,6 +259,59 @@ public function options( $args, $assoc_args ) : void {
259259 );
260260 }
261261 }
262+
263+ /**
264+ * Deploy Cache
265+ *
266+ * <delete>
267+ *
268+ * Empty all URLs from DeployCache
269+ *
270+ * @param string[] $args Arguments after command
271+ * @param string[] $assoc_args Parameters after command
272+ */
273+ public function deploy_cache ( array $ args , array $ assoc_args ) : void {
274+ $ action = isset ( $ args [0 ] ) ? $ args [0 ] : null ;
275+
276+ if ( empty ( $ action ) ) {
277+ WP_CLI ::error (
278+ 'Missing required argument: ' .
279+ '<delete> '
280+ );
281+ }
282+
283+ if ( $ action === 'delete ' ) {
284+
285+ if ( ! isset ( $ assoc_args ['force ' ] ) ) {
286+ $ this ->multilinePrint (
287+ "no --force given. Please type 'yes' to confirm
288+ deletion of Deploy Cache "
289+ );
290+
291+ $ userval = trim ( (string ) fgets ( STDIN ) );
292+
293+ if ( $ userval !== 'yes ' ) {
294+ WP_CLI ::error ( 'Failed to delete Deploy Cache ' );
295+ }
296+ }
297+
298+ $ instance = Controller::getInstance ();
299+ $ instance ->delete_deploy_cache ();
300+
301+ WP_CLI ::success ( 'Deleted Deploy Cache ' );
302+ }
303+ }
304+
305+ /**
306+ * Print multilines of input text via WP-CLI
307+ */
308+ public function multilinePrint ( string $ string ) : void {
309+ $ msg = trim ( str_replace ( [ "\r" , "\n" ], '' , $ string ) );
310+
311+ $ msg = preg_replace ( '!\s+! ' , ' ' , $ msg );
312+
313+ WP_CLI ::line ( PHP_EOL . $ msg . PHP_EOL );
314+ }
262315}
263316
264317/*
0 commit comments