WP_CLI\Dispatcher

CompositeCommand::get_global_params()protectedWP-CLI 1.0

Get the list of global parameters

Method of the class: CompositeCommand{}

No Hooks.

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_global_params( $root_command );
$root_command(string)
whether to include or not root command specific description
Default: false

CompositeCommand::get_global_params() code WP-CLI 2.8.0-alpha

protected function get_global_params( $root_command = false ) {
	$binding                 = [];
	$binding['root_command'] = $root_command;

	if ( ! $this->can_have_subcommands() || ( is_object( $this->parent ) && get_class( $this->parent ) === 'WP_CLI\Dispatcher\CompositeCommand' ) ) {
		$binding['is_subcommand'] = true;
	}

	foreach ( WP_CLI::get_configurator()->get_spec() as $key => $details ) {
		if ( false === $details['runtime'] ) {
			continue;
		}

		if ( isset( $details['deprecated'] ) ) {
			continue;
		}

		if ( isset( $details['hidden'] ) ) {
			continue;
		}

		if ( true === $details['runtime'] ) {
			$synopsis = "--[no-]$key";
		} else {
			$synopsis = "--$key" . $details['runtime'];
		}

		// Check if global parameters synopsis should be displayed or not.
		if ( 'true' !== getenv( 'WP_CLI_SUPPRESS_GLOBAL_PARAMS' ) ) {
			$binding['parameters'][]   = [
				'synopsis' => $synopsis,
				'desc'     => $details['desc'],
			];
			$binding['has_parameters'] = true;
		}
	}

	if ( $this->get_subcommands() ) {
		$binding['has_subcommands'] = true;
	}

	return Utils\mustache_render( 'man-params.mustache', $binding );
}