1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
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\t"),
country.country,
country.flag,
nano.green("\nLat/Lng\t\t\t"),
country.latlng,
nano.green("\nPopulation:\t\t"),
country.population,
nano.green("\nLanguages:\t\t"),
country.languages,
nano.green("\nCapital:\t\t"),
country.capital,
nano.green("\nCapital Lat/Lng:\t"),
country.capitalLatLng,
nano.green("\nRegion:\t\t\t"),
country.region,
nano.green("\nSubregion:\t\t"),
country.subregion,
nano.green("\nTimezones:\t\t"),
country.timezones,
nano.green("\nTop Level Domain:\t"),
country.tld,
nano.green("\nCurrencies:\t\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"
);
}
}
|