diff options
| author | Fridon <[email protected]> | 2022-06-23 00:01:12 +0400 |
|---|---|---|
| committer | Fridon <[email protected]> | 2022-06-23 00:01:12 +0400 |
| commit | 7d72153d68ea4c682266f0301aa45b4e3a9e45a9 (patch) | |
| tree | ba2b4b8937d0c7785a468fae18880762a5e6b484 /src/util/logger.ts | |
| parent | be829dad070205555c514ff497fcf2eae355a6e2 (diff) | |
| download | countryfetch-7d72153d68ea4c682266f0301aa45b4e3a9e45a9.tar.xz countryfetch-7d72153d68ea4c682266f0301aa45b4e3a9e45a9.zip | |
big refactor + raw option
Diffstat (limited to 'src/util/logger.ts')
| -rw-r--r-- | src/util/logger.ts | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/util/logger.ts b/src/util/logger.ts new file mode 100644 index 0000000..52965c8 --- /dev/null +++ b/src/util/logger.ts @@ -0,0 +1,77 @@ +import * as nano from "https://deno.land/x/[email protected]/mod.ts"; +import { FetchedCountry } from "../models/FetchedCountry.model.ts"; + +export class Logger { + public log(...data: any) { + console.log(data); + } + + public alert(...data: any) { + console.log(nano.yellow(data)); + } + + public success(...data: any) { + console.log(nano.green(data)); + } + + public error(...data: any) { + console.error(data); + } + + public logCountry(country: FetchedCountry) { + console.log( + nano.cyan("\nCountry:\t"), + country.country, + country.flag, + nano.green("\nLanguages:\t"), + country.languages, + nano.green("\nCapital:\t"), + country.capital, + nano.green("\nRegion:\t\t"), + country.region, + nano.green("\nPopulation:\t"), + country.population.toLocaleString(), + nano.green("\nCurrencies:\t"), + country.currencies + ); + } + + public capitalOf(capital: string, country: string) { + console.log( + nano.green(capital) + " is the capital of " + nano.cyan(country) + ); + } + + public help(): void { + console.log( + "\ncountryfetch\n", + "\tFetch information about countries", + "\n", + "\nUSAGE\n", + "\tcountryfetch <ARGS>", + "\n", + "\nARGS:\n", + "\tsync", + "\n\t\tSynchronize database. Stores countries' data in ~/.cache/conntryfetch/countries.json.", + "\n", + "\n\trandom", + "\n\t\tPrint information about a random country.", + "\n", + "\n\t<country_name>", + "\n\t\tPrint information about the specified country.", + "\n", + "\n", + "\n\tcapital <capital>", + "\n\t\tPrint country to which the specified capital belongs.", + "\n", + "\n", + "\n\traw <country_name>", + "\n\t\tPrint country information in raw format as JavaScript object.", + "\n", + "\nEXAMPLE:\n", + "\tcountryfetch germany", + "\n\t\tPrints information about Germany.", + "\n" + ); + } +} |
