Skip to content

Support strict output format #1004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open

Support strict output format #1004

wants to merge 3 commits into from

Conversation

ernilambar
Copy link
Member

@ernilambar ernilambar commented Jul 16, 2025

Fixes #748

  • Introduce more options for --format
    • strict-table
    • strict-csv
    • strict-json
  • With above new formats, FILE: part in the output will be omitted.
  • Added feature test for the changes

@ernilambar ernilambar force-pushed the 748-strict-format branch 3 times, most recently from 143b2dd to 73aeacc Compare July 16, 2025 05:54
@ernilambar ernilambar marked this pull request as ready for review July 16, 2025 07:03
@ernilambar ernilambar added this to the 1.6.0 milestone Jul 16, 2025
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @singerb.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: singerb.

Co-authored-by: ernilambar <[email protected]>
Co-authored-by: swissspidy <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ernilambar ernilambar added the Infrastructure Issues for the overall plugin infrastructure label Jul 16, 2025
@swissspidy
Copy link
Member

Why a separate flag and not something like --format=strict-json?

Should we perhaps just fix the existing json format? Or is it still useful?

Comment on lines +126 to +138
/**
* @Then /^STDOUT should be valid JSON$/
*/
public function stdout_should_be_valid_json() {
$output = $this->result->stdout;

json_decode( $output );

if ( JSON_ERROR_NONE !== json_last_error() ) {
throw new Exception( 'STDOUT is not valid JSON: ' . json_last_error_msg() );
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Nice!

@ernilambar
Copy link
Member Author

ernilambar commented Jul 16, 2025

Why a separate flag and not something like --format=strict-json?

That sounds like a good idea.

Should we perhaps just fix the existing json format? Or is it still useful?

That would be a major breaking change I believe. I dont want to break which is already working :-)

@ernilambar ernilambar changed the title Add flag for strict output format Support strict output format Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Issues for the overall plugin infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI: fully structured output for easier parsing, send to a file
2 participants