Skip to content

Commit 34cf6e1

Browse files
Remove pattern option
1 parent ba78e0d commit 34cf6e1

2 files changed

Lines changed: 4 additions & 28 deletions

File tree

‎src/SQLite_Command.php‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,9 @@ public function export( $args, $assoc_args ) {
106106
*
107107
* ## OPTIONS
108108
*
109-
* [<table>...]
110-
* : List tables based on wildcard search, e.g. 'wp_*_options' or 'wp_post?'.
111-
*
112109
* [--format=<format>]
113110
* : Render output in a particular format.
111+
*
114112
* ---
115113
* default: list
116114
* options:
@@ -135,13 +133,6 @@ public function export( $args, $assoc_args ) {
135133
* wp_usermeta
136134
* wp_users
137135
*
138-
* # List all tables matching wildcards
139-
* $ wp sqlite tables wp_comment* wp_post*
140-
* wp_commentmeta
141-
* wp_comments
142-
* wp_postmeta
143-
* wp_posts
144-
*
145136
* @when before_wp_load
146137
*/
147138
public function tables( $args, $assoc_args ) {
@@ -150,6 +141,6 @@ public function tables( $args, $assoc_args ) {
150141
}
151142

152143
$tables = new Tables();
153-
$tables->run( $args, $assoc_args );
144+
$tables->run( $assoc_args );
154145
}
155146
}

‎src/Tables.php‎

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,22 @@ protected function get_pdo() {
3333
/**
3434
* Lists all tables in the SQLite database.
3535
*
36-
* @param array|null $patterns Optional wildcard patterns to filter tables.
3736
* @param array $assoc_args Associative array of options.
3837
* @return void
3938
*/
40-
public function run( ?array $patterns = null, $assoc_args = [] ) {
39+
public function run( $assoc_args = [] ) {
4140
$pdo = $this->get_pdo();
4241

4342
// Get all tables
4443
$stmt = $pdo->query( "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'" );
4544
$tables = $stmt->fetchAll( PDO::FETCH_COLUMN );
4645

47-
// Filter tables if wildcard pattern is provided
48-
if ( ! empty( $patterns ) ) {
49-
foreach ( $patterns as $pattern ) {
50-
$tables = array_filter(
51-
$tables,
52-
fn ( $table ) => fnmatch( $pattern, $table, FNM_CASEFOLD )
53-
);
54-
}
55-
}
56-
5746
// Remove system tables
5847
$tables_to_exclude = array( '_mysql_data_types_cache' );
5948
$tables = array_diff( $tables, $tables_to_exclude );
6049

6150
if ( empty( $tables ) ) {
62-
if ( ! empty( $patterns ) ) {
63-
WP_CLI::error( 'No tables found.' );
64-
} else {
65-
WP_CLI::error( 'No tables found in the database.' );
66-
}
51+
WP_CLI::error( 'No tables found in the database.' );
6752
}
6853

6954
$format = \WP_CLI\Utils\get_flag_value( $assoc_args, 'format' );

0 commit comments

Comments
 (0)