Skip to content
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

Add the --format option with 'text' and 'ndjson' #11

Merged
merged 2 commits into from
Feb 7, 2023
Merged

Conversation

zmoog
Copy link
Owner

@zmoog zmoog commented Feb 7, 2023

Motivation

The CLI now offers a new --format option that supports the following formats:

  • text
  • ndjson

The text format renders the result using tables. This is the default format.

The ndjson format renders the result as JSON objects separated by a "\n". This is useful for using the data with other tools.

Change description

The Result classes now must support a ndjson() method alongside the current str() method. The ndjson() method must return an NDJSON representation of the data.

We added a new result.render() function for the cli module. This the function will take care of calling the proper method on the Result object, according to the format argument.

Additional Notes

Reviewer checklist

  • PR address a single concern.
  • PR title and description are appropriately filled.
  • Changes will be merged in main.
  • Changes are covered by tests.
  • Logging is meaningful in case of troubleshooting.
  • Docs are updated (at least the README.md, if needed).
  • History is clean, commit messages are meaningful (see CONTRIBUTING.md) and are well-formatted.

The CLI now offers a new `--format` option that supports the following
formats:

- `text`
- `ndjson`

The `text` format renders the result using tables. This is the default
format.

The `ndjson` format renders the result as JSON objects separated by a
"\n". This is useful for using the data with other tools.

***

The `Result` classes now must support a `ndjson()` method alongside
the current `str()` method. The `ndjson()` method must return an NDJSON
representation of the data.

We added a new `result.render()` function for the `cli` module. This
the function will take care of calling the proper method on the `Result`
object, according to the `format` argument.

refs: #7
@zmoog zmoog self-assigned this Feb 7, 2023
@zmoog zmoog added the enhancement New feature or request label Feb 7, 2023
@zmoog zmoog marked this pull request as ready for review February 7, 2023 05:57
@zmoog zmoog merged commit 3dd735c into main Feb 7, 2023
@zmoog zmoog deleted the zmoog/ndjson branch February 7, 2023 05:59
@zmoog zmoog mentioned this pull request Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant