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 JSON and NDJSON output formats #14

Merged
merged 6 commits into from
Mar 24, 2023
Merged

Add JSON and NDJSON output formats #14

merged 6 commits into from
Mar 24, 2023

Conversation

zmoog
Copy link
Owner

@zmoog zmoog commented Mar 24, 2023

Motivation

Using this axios CLI in combination with other tools requires having JSON-based output formats.

For example, I want to be able to do something like this:

$ axios grades list --output-format json | \
    jq '{"grades": .}' | \
    jinja -d - -f json templates/axios/grades.j2 | \
    tgm message send --chat-id ${CHAT_ID}

Change description

Move the formatting logic into a dedicated result module. In this module, the GradesListResult class will be responsible for formatting the result of the grades list command.

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 table rendering is not handled by a class in the
`result` nmodule.
Add a new `render()` function to render a `Result` object into a `str`
according to the `format`
A little more verbose, but also less ambiguous
@zmoog zmoog self-assigned this Mar 24, 2023
@zmoog zmoog added the enhancement New feature or request label Mar 24, 2023
@zmoog zmoog marked this pull request as ready for review March 24, 2023 06:01
@zmoog zmoog merged commit a5c6642 into main Mar 24, 2023
@zmoog zmoog deleted the zmoog/json branch March 24, 2023 06:02
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.

None yet

1 participant