public function block( $args, $assoc_args ) {

		$slug = $args[0];
		if ( ! preg_match( '/^[a-z][a-z0-9\-]*$/', $slug ) ) {
			WP_CLI::error( 'Invalid block slug specified. Block slugs can contain only lowercase alphanumeric characters or dashes, and start with a letter.' );
		}

		$defaults = array(
			'title'    => str_replace( '-', ' ', $slug ),
			'category' => 'widgets',
		);
		$data     = $this->extract_args( $assoc_args, $defaults );

		$data['slug']             = $slug;
		$data['title_ucfirst']    = ucfirst( $data['title'] );
		$data['title_ucfirst_js'] = esc_js( $data['title_ucfirst'] );

		$dashicon = $this->extract_dashicon( $assoc_args );
		if ( $dashicon ) {
			$data['dashicon'] = $dashicon;
		}

		$control_defaults = array(
			'force'  => false,
			'plugin' => false,
			'theme'  => false,
		);
		$control_args     = $this->extract_args( $assoc_args, $control_defaults );

		if ( isset( $control_args['plugin'] ) ) {
			if ( ! preg_match( '/^[A-Za-z0-9\-]*$/', $control_args['plugin'] ) ) {
				WP_CLI::error( 'Invalid plugin name specified. The block editor can only register blocks for plugins that have nothing but lowercase alphanumeric characters or dashes in their slug.' );
			}
		}

		$data['namespace']    = $control_args['plugin'] ? $control_args['plugin'] : $this->get_theme_name( $control_args['theme'] );
		$data['machine_name'] = $this->generate_machine_name( $slug );
		$data['plugin']       = $control_args['plugin'] ? true : false;
		$data['theme']        = ! $data['plugin'];

		$block_dir = $this->get_output_path( $control_args, '/blocks' );
		if ( ! $block_dir ) {
			WP_CLI::error( 'No plugin or theme selected.' );
		}

		$files_to_create = array(
			"{$block_dir}/{$slug}.php"        => self::mustache_render( 'block-php.mustache', $data ),
			"{$block_dir}/{$slug}/index.js"   => self::mustache_render( 'block-index-js.mustache', $data ),
			"{$block_dir}/{$slug}/editor.css" => self::mustache_render( 'block-editor-css.mustache', $data ),
			"{$block_dir}/{$slug}/style.css"  => self::mustache_render( 'block-style-css.mustache', $data ),
		);
		$files_written   = $this->create_files( $files_to_create, $control_args['force'] );
		$skip_message    = 'All block files were skipped.';
		$success_message = "Created block '{$data['title_ucfirst']}'.";
		$this->log_whether_files_written( $files_written, $skip_message, $success_message );
	}