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: Reverse order of output #40

Merged
merged 4 commits into from Mar 25, 2020

Conversation

@asharirfan
Copy link
Contributor

asharirfan commented Mar 24, 2020

Description

This PR adds --reverse flag to the CLI, which reverses the order of output.

Usage

corona --reverse
corona --sort cases --reverse
corona -s cases -r

Applicable Issues

#23

@ahmadawais

This comment has been minimized.

Copy link
Owner

ahmadawais commented Mar 24, 2020

Thank you, Ashar!

Please update the PR in light of the latest release.

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

@asharirfan

This comment has been minimized.

Copy link
Contributor Author

asharirfan commented Mar 25, 2020

Just updated the PR with the latest release.

@ahmadawais ahmadawais added the 📦 NEW label Mar 25, 2020
@@ -16,6 +16,7 @@ module.exports = meow(
Options
${yellow(`--xcolor`)}, ${yellow(`-x`)} Single colored output
${yellow(`--sort`)}, ${yellow(`-s`)} Sort data by type
${yellow(`--reverse`)}, ${yellow(`-r`)} Reverse the order of sorted data

This comment has been minimized.

Copy link
@ahmadawais

ahmadawais Mar 25, 2020

Owner

Smaller description is better.

@@ -41,6 +42,10 @@ module.exports = meow(
type: "string",
default: "cases",
alias: "s"
},
reverse: {
type: "string",

This comment has been minimized.

Copy link
@ahmadawais

ahmadawais Mar 25, 2020

Owner

You didn't define a default.

@@ -15,7 +15,11 @@ module.exports = async (spinner, table, states, countryName, sortBy) => {
let allCountries = response.data;

// Sort.
allCountries = orderBy(allCountries, [sortingKeys[sortBy]], ["desc"]);
if ( reverse !== undefined ) {

This comment has been minimized.

Copy link
@ahmadawais

ahmadawais Mar 25, 2020

Owner

The ternary operator would have been better here.

@@ -35,6 +39,9 @@ module.exports = async (spinner, table, states, countryName, sortBy) => {

spinner.stopAndPersist();
spinner.info(`${chalk.cyan(`Sorted by:`)} ${sortBy}`);
if ( reverse !== undefined ) {
spinner.info(`${chalk.cyan(`Order:`)} reverse`);

This comment has been minimized.

Copy link
@ahmadawais

ahmadawais Mar 25, 2020

Owner

Too much info.

@ahmadawais

This comment has been minimized.

Copy link
Owner

ahmadawais commented Mar 25, 2020

Thank you, Ashar. Accepting the PR but do read the comments. I'll address them myself.

@ahmadawais ahmadawais merged commit 8a6b8d0 into ahmadawais:master Mar 25, 2020
@ahmadawais

This comment has been minimized.

Copy link
Owner

ahmadawais commented Mar 25, 2020

Also why is reverse a string?

@ahmadawais

This comment has been minimized.

Copy link
Owner

ahmadawais commented Mar 25, 2020

Inukares added a commit to Inukares/corona-cli that referenced this pull request Mar 25, 2020
* 📦 NEW: Reverse sorting flag

* 📦 NEW: Reverse data sorting using reverse flag

* 📖 DOC: Reverse sorting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.