Skip to content

Add db columns command#100

Merged
schlessera merged 10 commits intomasterfrom
show-columns
May 15, 2018
Merged

Add db columns command#100
schlessera merged 10 commits intomasterfrom
show-columns

Conversation

@swissspidy
Copy link
Copy Markdown
Member

Implements wp-cli/ideas#97.

Not sure if it's worth adding to the package, but I figured it might be useful.


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

WP_CLI\Utils\wp_get_table_names( [ $args[0] ], [] );
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to use array() syntax.

@@ -0,0 +1,40 @@
Feature: Display information about a given table.

Scenario: Display information about the wp_posts table
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schema might not be the same for older WordPress versions. A minimum version should be added.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the last change to the database schema was for WP 4.2, so adding the following should work: @require-wp-4.2

'format' => $format,
);

$formatter = new Formatter($formatter_args, array( 'Field', 'Type', 'Null', 'Key', 'Default', 'Extra' ) );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CS - Space missing before $formatter_args.

* +-----------------------+---------------------+------+-----+---------------------+----------------+
*
* @when after_wp_load
* @alias fields
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should skip the alias and only use multiple names for BC reasons.

@@ -0,0 +1,40 @@
Feature: Display information about a given table.

Scenario: Display information about the wp_posts table
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the last change to the database schema was for WP 4.2, so adding the following should work: @require-wp-4.2

README.md Outdated

### wp db columns

Display information about a given table.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Display => Displays

README.md Outdated
**OPTIONS**

[<table>]
Table name
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Table name => Name of the database table.

README.md Outdated
Table name

[--format]
table, csv, json
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add description:

Render output in a particular format.

[<table>]
Table name

[--format]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be: [--format=<format>]

options:
- table
- csv
- json
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should include yaml

'format' => $format,
);

$formatter = new Formatter($formatter_args, array( 'Field', 'Type', 'Null', 'Key', 'Default', 'Extra' ) );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given $formatter_args is built in a separate variable, the header fields should get the same treatment, especially as they produce a very long line here.

@schlessera
Copy link
Copy Markdown
Member

You should also adapt the file https://github.com/wp-cli/db-command/blob/master/.github/settings.yml to add the command:db-columns to the settings.

@swissspidy swissspidy requested a review from schlessera May 9, 2018 07:36
@schlessera schlessera merged commit c9b7a5e into master May 15, 2018
@schlessera schlessera deleted the show-columns branch May 15, 2018 15:37
@schlessera schlessera added this to the 1.3.4 milestone May 15, 2018
@schlessera schlessera changed the title Show columns Add db columns command May 15, 2018
danielbachhuber pushed a commit that referenced this pull request Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants