] * : Number of bounded batches (1-20). Default: 1. * * @param mixed $args Positional arguments (none). * @param mixed $assoc_args Named arguments: batches. */ public function work( $args, $assoc_args ): void { if ( Settings::get()['paused'] ) { \WP_CLI::error( 'Processing is paused. Resume in Image Manager first.' ); } $batches = max( 1, min( 20, absint( $assoc_args['batches'] ?? 1 ) ) ); for ( $i = 0; $i < $batches && Workflow::pending(); ++$i ) { Workflow::run_batch( 'cli' ); if ( $i + 1 < $batches ) { sleep( 1 ); } } \WP_CLI::line( wp_json_encode( Workflow::snapshot(), JSON_PRETTY_PRINT ) ); } /** * Schedule (but do not execute) an independent health probe. * * @param mixed $args Positional arguments (none). * @param mixed $assoc_args Named arguments (none). * @subcommand test-background */ public function test_background( $args, $assoc_args ): void { Scheduler::check( true ); \WP_CLI::line( wp_json_encode( Scheduler::status(), JSON_PRETTY_PRINT ) ); } }