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

NEW: Implement full JSON output, without changing existing logic #76

Merged
merged 16 commits into from Apr 23, 2020

Conversation

mifkata
Copy link
Contributor

@mifkata mifkata commented Apr 6, 2020

issue #11

Overview

This PR is about changing the output format from Table to JsonOutput (a simplified Json formatter). It doesn't change anything about current logic in regards to data fetching and sorting. The only difference is that:

  • All other outputs are silenced, so you can corona --json > output.json
  • Changes the format of numbers to not use comma-number, but instead return plain integers
  • When cli.flags.json === true all coloring functions in utils/table.js will return plain text instead
  • Outputs JSON

How to test

  • corona --json - normal run
  • corona -j - same as above using short-handle
  • corona --json > output.json - output to output.json and check the formatting (Prettifying JSON helps)

@mifkata
Copy link
Contributor Author

mifkata commented Apr 23, 2020

@ahmadawais Hello, just a friendly reminder to review this :) Thank you!


(async () => {
// Init.
await init(minimal);
init(minimal || json);
Copy link
Owner

Choose a reason for hiding this comment

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

await is needed so the update check will run before the spinner.

Copy link
Owner

@ahmadawais ahmadawais left a comment

Choose a reason for hiding this comment

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

Looks good to me! ✔︎

@ahmadawais ahmadawais merged commit 5a2315e into ahmadawais:master Apr 23, 2020
@mifkata mifkata deleted the issue-11-format-as-json branch April 23, 2020 12:24
@ahmadawais
Copy link
Owner

🔗 https://github.com/ahmadawais/corona-cli/releases/tag/5.1.0
🔗 https://www.npmjs.com/package/corona-cli

Thanks a lot @mifkata for working on this.

One improvement I can think of is that the keys for JSON could be

country, cases, 'cases-today', deaths, 'deaths-today', recovered, active, critical, 'per-million'.

@mifkata
Copy link
Contributor Author

mifkata commented Apr 23, 2020

One improvement I can think of is that the keys for JSON could be

country, cases, 'cases-today', deaths, 'deaths-today', recovered, active, critical, 'per-million'.

Do you want me to open a PR for it @ahmadawais ? :)

@ahmadawais
Copy link
Owner

ahmadawais commented Apr 23, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants