diff options
| author | Pridon Tetradze <[email protected]> | 2022-06-26 13:46:59 +0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-06-26 13:46:59 +0400 |
| commit | 2e058526d896ab4ee5173ceb80d1248ac08ff594 (patch) | |
| tree | 9550b812ea66f069396fef043cff1d10aeaec859 /src/util | |
| parent | 8626e2d8e258e11837d27a1e99ef3277e7dfdf3b (diff) | |
| download | countryfetch-2e058526d896ab4ee5173ceb80d1248ac08ff594.tar.xz countryfetch-2e058526d896ab4ee5173ceb80d1248ac08ff594.zip | |
Flag ASCII art, remove tabularization & refactor (#3)
* initial flag image converter
* add flags caching
* refactor, remove tabularization, make flag ASCII optional.
* update readme
* update readme
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/image-converter.ts | 22 | ||||
| -rw-r--r-- | src/util/logger.ts | 30 |
2 files changed, 38 insertions, 14 deletions
diff --git a/src/util/image-converter.ts b/src/util/image-converter.ts new file mode 100644 index 0000000..17d070a --- /dev/null +++ b/src/util/image-converter.ts @@ -0,0 +1,22 @@ +import { + printImage, + getImageStrings, +} from "https://x.nest.land/[email protected]/mod.ts"; +import { environment } from "../environment/environment.ts"; + +export class ImageConverter { + width = environment.flagWidth; + public getImageStrings(path: string) { + return getImageStrings({ + path, + width: this.width, + }); + } + + public printImage(path: string) { + return printImage({ + path, + width: this.width, + }); + } +} diff --git a/src/util/logger.ts b/src/util/logger.ts index aaa92c5..58745b7 100644 --- a/src/util/logger.ts +++ b/src/util/logger.ts @@ -1,8 +1,8 @@ import * as nano from "https://deno.land/x/[email protected]/mod.ts"; -import { FetchedCountry } from "../models/FetchedCountry.model.ts"; +import { FetchedCountry } from "../models/fetched-country.model.ts"; export class Logger { - public log(...data: any) { + public log(data: any) { console.log(data); } @@ -15,33 +15,33 @@ export class Logger { } public error(...data: any) { - console.error(data); + console.error(nano.red(data)); } public logCountry(country: FetchedCountry) { console.log( - nano.cyan("\nCountry:\t\t"), + nano.cyan("Country:"), country.country, country.flag, - nano.green("\nLat/Lng\t\t\t"), + nano.green("\nLat/Lng:"), country.latlng, - nano.green("\nPopulation:\t\t"), + nano.green("\nPopulation:"), country.population, - nano.green("\nLanguages:\t\t"), + nano.green("\nLanguages:"), country.languages, - nano.green("\nCapital:\t\t"), + nano.green("\nCapital:"), country.capital, - nano.green("\nCapital Lat/Lng:\t"), + nano.green("\nCapital Lat/Lng:"), country.capitalLatLng, - nano.green("\nRegion:\t\t\t"), + nano.green("\nRegion:"), country.region, - nano.green("\nSubregion:\t\t"), + nano.green("\nSubregion:"), country.subregion, - nano.green("\nTimezones:\t\t"), + nano.green("\nTimezones:"), country.timezones, - nano.green("\nTop Level Domain:\t"), + nano.green("\nTop Level Domain:"), country.tld, - nano.green("\nCurrencies:\t\t"), + nano.green("\nCurrencies:"), country.currencies ); } @@ -63,6 +63,8 @@ export class Logger { "\nARGS:\n", "\tsync", "\n\t\tSynchronize database. Stores countries' data in ~/.cache/conntryfetch/countries.json.", + "\n\t\tPass additional argument 'sync flag' to fetch and convert flags in ASCII art.", + "\n\t\tAfter syncing flags, every countryfetch command will display flag ASCII art.", "\n", "\n\trandom", "\n\t\tPrint information about a random country.", |
