# xspeed/1.3.0/includes/class-cli-manager.php

xSpeed Cache: AI-Powered Performance Hub with MCP, Caching &amp; CDN, version 1.3.0. 44 lines.

- Page: https://pluginprobe.com/plugins/xspeed/1.3.0/code/includes/class-cli-manager.php
- Raw: https://pluginprobe.com/plugins/xspeed/1.3.0/raw/includes/class-cli-manager.php
- Modified: 2026-06-01T17:33:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/xspeed/1.3.0/code/includes/class-cli-manager.php#L10-L20`.

```php
<?php
/**
 * CLI_Manager — registers a module's WP-CLI commands under the
 * `wp xspeed <module> ...` namespace.
 *
 * Loaded only when WP_CLI is defined and truthy (Module_Registry guards
 * the call). Modules declare commands via Module::cli_commands().
 *
 * The full xSpeed CLI surface is enumerated in FEATURES.md → "xSpeed CLI"
 * section (24 planned commands across all modules). Each handler shares
 * its core function with the matching REST callback — no duplicated
 * validation paths.
 *
 * @package XSpeed
 */

namespace XSpeed;

defined( 'ABSPATH' ) || exit;

final class Cli_Manager {

	public static function register_module( Module $module ): void {
		if ( ! ( defined( 'WP_CLI' ) && WP_CLI ) ) {
			return;
		}
		foreach ( $module->cli_commands() as $cmd ) {
			$name     = $cmd['name'] ?? '';
			$callback = $cmd['callback'] ?? null;
			if ( '' === $name || ! is_callable( $callback ) ) {
				continue;
			}
			$args = array();
			if ( isset( $cmd['synopsis'] ) ) {
				$args['synopsis'] = $cmd['synopsis'];
			}
			if ( isset( $cmd['shortdesc'] ) ) {
				$args['shortdesc'] = $cmd['shortdesc'];
			}
			\WP_CLI::add_command( $name, $callback, $args );
		}
	}
}

```
