<?php

namespace Waypoint\Agent\Cli;

use Waypoint\Agent\Admin\Flush_Everything;
use Waypoint\Agent\Base\Thing;

class Cache_Flush extends Thing {

	public function attach_hooks(): void {
		\WP_CLI::add_hook( 'after_invoke:cache flush', [ $this, 'run' ] );
	}

	public function run(): void {
		$log = ( new Flush_Everything() )->run();
		foreach ( $log as $line ) {
			\WP_CLI::log( '  ' . $line );
		}
	}
}
