<commit_before><?php

use \WP_CLI\Utils;

/**
 * Perform basic database operations.
 *
 * ## OPTIONS
 *
 * --yes
 * : Answer yes to the confirmation message.
 *
 * <file>
 * : The name of the export file. If omitted, it will be '{dbname}.sql'
 *
 * <SQL>
 * : A SQL query.
 *
 * ## EXAMPLES
 *
 *     # execute a query stored in a file
 *     wp db query < debug.sql
 */
class DB_Command extends WP_CLI_Command {

	/**
	 * Create the database, as specified in wp-config.php
	 */
	function create( $_, $assoc_args ) {
		self::run_query( sprintf( 'CREATE DATABASE `%s`', DB_NAME ) );

		WP_CLI::success( "Database created." );
	}

	/**
	 * Delete the database.
	 *
	 * @synopsis [--yes]
	 */
	function drop( $_, $assoc_args ) {
		WP_CLI::confirm( "Are you sure you want to drop the database?", $assoc_args );

		self::run_query( sprintf( 'DROP DATABASE `%s`', DB_NAME ) );

		WP_CLI::success( "Database dropped." );
	}

	/**
	 * Remove all tables from the database.
	 *
	 * @synopsis [--yes]
	 */
	function reset( $_, $assoc_args ) {
		WP_CLI::confirm( "Are you sure you want to reset the database?", $assoc_args );

		self::run_query( sprintf( 'DROP DATABASE IF EXISTS `%s`', DB_NAME ) );
		self::run_query( sprintf( 'CREATE DATABASE `%s`', DB_NAME ) );

		WP_CLI::success( "Database reset." );
	}

	/**
	 * Optimize the database.
	 */
	function optimize() {
		self::run( Utils\esc_cmd( 'mysqlcheck %s', DB_NAME ), array(
			'optimize' => true,
		) );

		WP_CLI::success( "Database optimized." );
	}

	/**
	 * Repair the database.
	 */
	function repair() {
		self::run( Utils\esc_cmd( 'mysqlcheck %s', DB_NAME ), array(
			'repair' => true,
		) );

		WP_CLI::success( "Database repaired." );
	}

	/**
	 * Open a mysql console using the WordPress credentials.
	 *
	 * @alias connect
	 */
	function cli() {
		self::run( 'mysql --no-defaults', array(
			'database' => DB_NAME
		) );
	}

	/**
	 * Execute a query against the database.
	 *
	 * @synopsis [<sql>]
	 */
	function query( $args ) {
		$assoc_args = array(
			'database' => DB_NAME
		);

		// The query might come from STDIN
		if ( !empty( $args ) ) {
			$assoc_args['execute'] = $args[0];
		}

		self::run( 'mysql --no-defaults', $assoc_args );
	}

	/**
	 * Exports the database using mysqldump. Accepts all of mysqldump's arguments.
	 *
	 * @alias dump
	 *
	 * @synopsis [<file>] [--extended-insert=FALSE] [--comments] [--replace] ...
	 */
	function export( $args, $assoc_args ) {
		$assoc_args['result-file'] = $this->get_file_name( $args );
<commit_msg>Add assoc arg for arbitrary mysqldump args<commit_after><?php

use \WP_CLI\Utils;

/**
 * Perform basic database operations.
 *
 * ## OPTIONS
 *
 * --yes
 * : Answer yes to the confirmation message.
 *
 * <file>
 * : The name of the export file. If omitted, it will be '{dbname}.sql'
 *
 * <SQL>
 * : A SQL query.
 *
 * ## EXAMPLES
 *
 *     # execute a query stored in a file
 *     wp db query < debug.sql
 */
class DB_Command extends WP_CLI_Command {

	/**
	 * Create the database, as specified in wp-config.php
	 */
	function create( $_, $assoc_args ) {
		self::run_query( sprintf( 'CREATE DATABASE `%s`', DB_NAME ) );

		WP_CLI::success( "Database created." );
	}

	/**
	 * Delete the database.
	 *
	 * @synopsis [--yes]
	 */
	function drop( $_, $assoc_args ) {
		WP_CLI::confirm( "Are you sure you want to drop the database?", $assoc_args );

		self::run_query( sprintf( 'DROP DATABASE `%s`', DB_NAME ) );

		WP_CLI::success( "Database dropped." );
	}

	/**
	 * Remove all tables from the database.
	 *
	 * @synopsis [--yes]
	 */
	function reset( $_, $assoc_args ) {
		WP_CLI::confirm( "Are you sure you want to reset the database?", $assoc_args );

		self::run_query( sprintf( 'DROP DATABASE IF EXISTS `%s`', DB_NAME ) );
		self::run_query( sprintf( 'CREATE DATABASE `%s`', DB_NAME ) );

		WP_CLI::success( "Database reset." );
	}

	/**
	 * Optimize the database.
	 */
	function optimize() {
		self::run( Utils\esc_cmd( 'mysqlcheck %s', DB_NAME ), array(
			'optimize' => true,
		) );

		WP_CLI::success( "Database optimized." );
	}

	/**
	 * Repair the database.
	 */
	function repair() {
		self::run( Utils\esc_cmd( 'mysqlcheck %s', DB_NAME ), array(
			'repair' => true,
		) );

		WP_CLI::success( "Database repaired." );
	}

	/**
	 * Open a mysql console using the WordPress credentials.
	 *
	 * @alias connect
	 */
	function cli() {
		self::run( 'mysql --no-defaults', array(
			'database' => DB_NAME
		) );
	}

	/**
	 * Execute a query against the database.
	 *
	 * @synopsis [<sql>]
	 */
	function query( $args ) {
		$assoc_args = array(
			'database' => DB_NAME
		);

		// The query might come from STDIN
		if ( !empty( $args ) ) {
			$assoc_args['execute'] = $args[0];
		}

		self::run( 'mysql --no-defaults', $assoc_args );
	}

	/**
	 * Exports the database using mysqldump. Accepts all of mysqldump's arguments.
	 *
	 * @alias dump
	 *
	 * @synopsis [<file>] [--extended-insert] [--skip-comments] [--<field>=<value>]
	 */
	function export( $args, $assoc_args ) {
		$assoc_args['result-file'] = $this->get_file_name( $args );

{'fraction_non_alphanumeric': 0.17293233082706766, 'fraction_numerical': 0.0003957261574990107, 'mean_word_length': 3.0635048231511255, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2534644', 'n_tokens_mistral': 1987, 'n_tokens_neox': 1800, 'n_words': 482}