Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions features/sqlite_tables.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ Feature: WP-CLI SQLite Tables Command
"""
wp_users,wp_usermeta,wp_termmeta,wp_terms,wp_term_taxonomy,wp_term_relationships,wp_commentmeta,wp_comments,wp_links,wp_options,wp_postmeta,wp_posts
"""

@require-sqlite
Scenario: Successfully list the tables in the SQLite database in a CSV format
When I run `wp sqlite tables --format=json`
Then STDOUT should contain:
"""
["wp_users","wp_usermeta","wp_termmeta","wp_terms","wp_term_taxonomy","wp_term_relationships","wp_commentmeta","wp_comments","wp_links","wp_options","wp_postmeta","wp_posts"]
"""
2 changes: 2 additions & 0 deletions src/Tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public function run( $assoc_args = [] ) {

if ( 'csv' === $format ) {
WP_CLI::line( implode( ',', $tables ) );
} elseif ( 'json' === $format ) {
WP_CLI::line( json_encode( array_values( $tables ) ) );
} else {
foreach ( $tables as $table ) {
WP_CLI::line( $table );
Expand Down
Loading