Skip to content

Comments

Feature/add export command#52

Merged
jeffpaul merged 9 commits intodevelopfrom
feature/add-export-command
May 13, 2024
Merged

Feature/add export command#52
jeffpaul merged 9 commits intodevelopfrom
feature/add-export-command

Conversation

@dsawardekar
Copy link
Collaborator

@dsawardekar dsawardekar commented Apr 17, 2024

Description of the Change

This PR adds a new WP_CLI export command to generate an export of the Block Catalog in CSV format.

  wp block-catalog export

DESCRIPTION

  Exports the posts associated with the 'block_catalog' taxonomy to a CSV file.

SYNOPSIS

  wp block-catalog export [--output=<output>] [--post_type=<types>] [--posts_per_block=<number>] [--ignore_parent=<ignore_parent>]

OPTIONS

  [--output=<output>]
    Path to the CSV file. Defaults to /tmp/block-catalog.csv

  [--post_type=<types>]
    Comma-delimited list of post types. Optional.

  [--posts_per_block=<number>]
    Number of posts per block, default to -1 (all). Optional.

  [--ignore_parent=<ignore_parent>]
    Ignore top level blocks. Optional. Default true

Generated CSV,

block_name block_slug post_id post_type post_title permalink status
Paragraph core-paragraph 1 post Hello world! http://block-catalog.test/2023/11/23/hello-world/ publish
Paragraph core-paragraph 2 page Sample Page http://block-catalog.test/sample-page/ publish
Quote core-quote 2 page Sample Page http://block-catalog.test/sample-page/ publish

How to test the Change

Run the WP_CLI export command. It should iterate over the catalog and generate an output CSV.

$ wp block-catalog export --output=test.csv && less test.csv

Changelog Entry

Added - Export command to generate a CSV of the block catalog.

Credits

Props @dsawardekar, @psorensen

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@dsawardekar dsawardekar marked this pull request as ready for review April 17, 2024 11:00
@dsawardekar dsawardekar requested a review from a team as a code owner April 17, 2024 11:00
@dsawardekar dsawardekar requested review from peterwilsoncc and removed request for a team April 17, 2024 11:00
@jeffpaul jeffpaul added this to the 1.6.0 milestone Apr 17, 2024
@jeffpaul jeffpaul requested a review from Sidsector9 May 7, 2024 13:14
Copy link
Member

@Sidsector9 Sidsector9 left a comment

Choose a reason for hiding this comment

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

The code looks good, only a minor bug:

Screenshot 2024-05-08 at 14 35 41

The error message is printed as success.

@dsawardekar
Copy link
Collaborator Author

@Sidsector9 Good catch, fixed here,

2ff418d

@dsawardekar dsawardekar requested a review from Sidsector9 May 8, 2024 10:08
@jeffpaul jeffpaul merged commit 377f657 into develop May 13, 2024
@jeffpaul jeffpaul deleted the feature/add-export-command branch May 13, 2024 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants