From 08512a396ce3ed35b984492c102e913d25ec8f8f Mon Sep 17 00:00:00 2001 From: Touch Sungkawichai Date: Wed, 25 Mar 2020 02:59:15 +0700 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=93=A6=20NEW:=20NonVerbose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 19 +++++++++++++------ utils/cli.js | 10 ++++++++++ utils/init.js | 3 ++- utils/table.js | 6 +++++- utils/theEnd.js | 3 ++- 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 2763f8d..31b7278 100755 --- a/index.js +++ b/index.js @@ -24,14 +24,17 @@ const { colored, singleStates, coloredStates, - style + style, + tab_borderless } = require("./utils/table.js"); const xcolor = cli.flags.xcolor; const sortBy = cli.flags.sort; +const quiet = cli.flags.quiet; +const borderless = cli.flags.borderless; (async () => { // Init. - init(); + init(quiet); const [input] = cli.input; await showHelp(); const states = input === "states" ? true : false; @@ -41,8 +44,13 @@ const sortBy = cli.flags.sort; const head = xcolor ? single : colored; const headStates = xcolor ? singleStates : coloredStates; const table = !states - ? new Table({ head, style }) - : new Table({ head: headStates, style }); + ? borderless + ? new Table({ head, style, chars:tab_borderless }) + : new Table({ head, style }) + : borderless + ? new Table({ head: headStates, style, chars:tab_borderless }) + : new Table({ head: headStates, style}); + // Display data. spinner.start(); @@ -50,6 +58,5 @@ const sortBy = cli.flags.sort; await getCountry(spinner, table, states, country); await getStates(spinner, table, states, sortBy); await getAll(spinner, table, states, country, sortBy); - - theEnd(lastUpdated, states); + theEnd(lastUpdated, states, quiet); })(); diff --git a/utils/cli.js b/utils/cli.js index beef82d..b1fb783 100644 --- a/utils/cli.js +++ b/utils/cli.js @@ -41,6 +41,16 @@ module.exports = meow( type: "string", default: "cases", alias: "s" + }, + quiet: { + type: "boolean", + defualt: true, + alias: "q" + }, + borderless: { + type: "boolean", + defualt: true, + alias: "b" } } } diff --git a/utils/init.js b/utils/init.js index 7e2c161..69eefa1 100644 --- a/utils/init.js +++ b/utils/init.js @@ -2,7 +2,8 @@ const welcome = require("cli-welcome"); const pkgJSON = require("./../package.json"); const updateNotifier = require("update-notifier"); -module.exports = async () => { +module.exports = async (quiet) => { + if (quiet) return welcome(`corona-cli`, `by Awais.dev\n${pkgJSON.description}`, { bgColor: `#007C91`, color: `#FFFFFF`, diff --git a/utils/table.js b/utils/table.js index 7f513ae..15064c9 100644 --- a/utils/table.js +++ b/utils/table.js @@ -47,6 +47,10 @@ module.exports = { `Active` ], style: { head: ["cyan"] }, + tab_borderless: { 'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': '' + , 'bottom': '' , 'bottom-mid': '' , 'bottom-left': '' , 'bottom-right': '' + , 'left': '' , 'left-mid': '' , 'mid': '' , 'mid-mid': '' + , 'right': '' , 'right-mid': '' , 'middle': ' ' }, sortingKeys: { country: "country", cases: "cases", @@ -66,4 +70,4 @@ module.exports = { "deaths-today": "todayDeaths", active: "active" } -}; +}; \ No newline at end of file diff --git a/utils/theEnd.js b/utils/theEnd.js index 3aa30d0..2baa9b3 100644 --- a/utils/theEnd.js +++ b/utils/theEnd.js @@ -33,7 +33,8 @@ ${dim(`❯ `)}${cyan(`Per Million:`)} Affected patients per million `) ); -module.exports = async (lastUpdated, states) => { +module.exports = async (lastUpdated, states, quiet) => { + if (quiet) return console.log(dim(`${sym.info} ${cyan(`Last Updated:`)} ${lastUpdated}`)); states && infoStates(); !states && infoCountries(); From 377a3bb9e363273e6923d7e33e01b0ac01b6c04c Mon Sep 17 00:00:00 2001 From: Touch Sungkawichai Date: Wed, 25 Mar 2020 11:38:01 +0700 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20Rename=20option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 16 ++++++++++++++++ index.js | 25 ++++++++++++------------- package.json | 2 +- utils/cli.js | 9 ++------- utils/{getAll.js => getCountries.js} | 0 utils/table.js | 7 ++++--- 6 files changed, 35 insertions(+), 24 deletions(-) rename utils/{getAll.js => getCountries.js} (100%) diff --git a/changelog.md b/changelog.md index ebdf870..f33064c 100644 --- a/changelog.md +++ b/changelog.md @@ -29,6 +29,18 @@ I have released a video course to help you become a better developer — +### RELEASE: [3.4.0](https://github.com/ahmadawais/corona-cli/compare/3.3.0...3.4.0) + +![👌 IMPROVE:](https://img.shields.io/badge/-IMPROVEMENT-gray.svg?colorB=39AA54) + +> 👌 Lingo [`36d3f89`](https://github.com/ahmadawais/corona-cli/commit/36d3f89d31cf6f1f067d009c4697e52b1666b6c3)
+ +
+ +[![hr](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/hr.png)](/) + +
+ ### RELEASE: [3.3.0](https://github.com/ahmadawais/corona-cli/compare/3.2.0...3.3.0) ![📦 NEW:](https://img.shields.io/badge/-NEW-gray.svg?colorB=3778FF) @@ -39,6 +51,10 @@ I have released a video course to help you become a better developer —
👌 Order + Flexibility [`7a6e824`](https://github.com/ahmadawais/corona-cli/commit/7a6e824c60a0f50793ca7536a47ac151e82c81e1)
+![📖 DOC:](https://img.shields.io/badge/-DOCS-gray.svg?colorB=978CD4) + +> 📖 Changelog [`e73216b`](https://github.com/ahmadawais/corona-cli/commit/e73216bb4d895dd7d664aaff77408c51794a43ec)
+
[![hr](https://raw.githubusercontent.com/ahmadawais/stuff/master/images/git/hr.png)](/) diff --git a/index.js b/index.js index 31b7278..3b32774 100755 --- a/index.js +++ b/index.js @@ -12,7 +12,7 @@ const spinner = ora({ text: "" }); const Table = require("cli-table3"); const cli = require("./utils/cli.js"); const init = require("./utils/init.js"); -const getAll = require("./utils/getAll.js"); +const getCountries = require("./utils/getCountries.js"); const showHelp = require("./utils/showHelp.js"); const theEnd = require("./utils/theEnd.js"); const handleError = require("cli-handle-error"); @@ -25,16 +25,15 @@ const { singleStates, coloredStates, style, - tab_borderless + borderless } = require("./utils/table.js"); const xcolor = cli.flags.xcolor; const sortBy = cli.flags.sort; -const quiet = cli.flags.quiet; -const borderless = cli.flags.borderless; +const minimal = cli.flags.minimal; (async () => { // Init. - init(quiet); + init(minimal); const [input] = cli.input; await showHelp(); const states = input === "states" ? true : false; @@ -43,13 +42,12 @@ const borderless = cli.flags.borderless; // Table const head = xcolor ? single : colored; const headStates = xcolor ? singleStates : coloredStates; - const table = !states + const border = minimal ? borderless - ? new Table({ head, style, chars:tab_borderless }) - : new Table({ head, style }) - : borderless - ? new Table({ head: headStates, style, chars:tab_borderless }) - : new Table({ head: headStates, style}); + : {}; + const table = !states + ? new Table({ head, style, chars:border }) + : new Table({ head: headStates, style, chars:border }); // Display data. @@ -57,6 +55,7 @@ const borderless = cli.flags.borderless; const lastUpdated = await getWorldwide(table, states); await getCountry(spinner, table, states, country); await getStates(spinner, table, states, sortBy); - await getAll(spinner, table, states, country, sortBy); - theEnd(lastUpdated, states, quiet); + await getCountries(spinner, table, states, country, sortBy); + + theEnd(lastUpdated, states, minimal); })(); diff --git a/package.json b/package.json index d426b48..8ab391f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "corona-cli", - "version": "3.3.0", + "version": "3.4.0", "description": "Track the Coronavirus disease (COVID-19).", "license": "MIT", "repository": "ahmadawais/corona-cli", diff --git a/utils/cli.js b/utils/cli.js index b1fb783..22e01ce 100644 --- a/utils/cli.js +++ b/utils/cli.js @@ -42,15 +42,10 @@ module.exports = meow( default: "cases", alias: "s" }, - quiet: { + minimal: { type: "boolean", defualt: true, - alias: "q" - }, - borderless: { - type: "boolean", - defualt: true, - alias: "b" + alias: "m" } } } diff --git a/utils/getAll.js b/utils/getCountries.js similarity index 100% rename from utils/getAll.js rename to utils/getCountries.js diff --git a/utils/table.js b/utils/table.js index 15064c9..aa9100a 100644 --- a/utils/table.js +++ b/utils/table.js @@ -1,6 +1,7 @@ const chalk = require("chalk"); const green = chalk.green; const red = chalk.red; +const yellow = chalk.yellow; const dim = chalk.dim; module.exports = { @@ -24,7 +25,7 @@ module.exports = { `${red(`Deaths`)}`, `${red(`Deaths (today)`)}`, `${green(`Recovered`)}`, - `Active`, + `${yellow(`Active`)}`, `${red(`Critical`)}`, `Per Million` ], @@ -44,10 +45,10 @@ module.exports = { `Cases ${dim(`(today)`)}`, `${red(`Deaths`)}`, `${red(`Deaths (today)`)}`, - `Active` + `${yellow(`Active`)}` ], style: { head: ["cyan"] }, - tab_borderless: { 'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': '' + borderless: { 'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': '' , 'bottom': '' , 'bottom-mid': '' , 'bottom-left': '' , 'bottom-right': '' , 'left': '' , 'left-mid': '' , 'mid': '' , 'mid-mid': '' , 'right': '' , 'right-mid': '' , 'middle': ' ' },