Countryfetchという色々な国に情報をscreenfetchのような形式で表示してくれるcliアプリケーションを知ったので試してみました.
とりあえずreleasesからbinaryをもらってきて試します.
$ wget2 -cv https://github.com/nik-rev/countryfetch/releases/download/v0.1.9/countryfetch-x86_64-unknown-linux-gnu.tar.xz \ https://github.com/nik-rev/countryfetch/releases/download/v0.1.9/countryfetch-x86_64-unknown-linux-gnu.tar.xz.sha256 $ sha256sum -c countryfetch-x86_64-unknown-linux-gnu.tar.xz.sha256 countryfetch-x86_64-unknown-linux-gnu.tar.xz: OK $ countryfetch-x86_64-unknown-linux-gnu/countryfetch-x86_64-unknown-linux-gnu/countryfetch --help
A Command-line tool similar to Neofetch for obtaining information about your country Usage: countryfetch [OPTIONS] [COUNTRY]... Arguments: [COUNTRY]... Options: --all-countries Print information about all countries --list-countries Print a list of all countries that can be passed -h, --help Print help -V, --version Print version Config: --no-area Exclude information about area of country --no-flag Exclude ASCII flag art --no-emoji Exclude country emoji --no-continent Exclude continent --no-population Exclude population --no-tld Exclude top-level domain --no-languages Exclude languages --no-currency Exclude currency --no-neighbours Exclude neighbours --no-established-date Exclude established date --no-iso-codes Exclude iso codes --no-driving-side Exclude driving side --no-capital Exclude capital --no-dialing-code Exclude dialing code --no-palette Exclude the country flag's palette --no-color No colored output $ countryfetch-x86_64-unknown-linux-gnu/countryfetch-x86_64-unknown-linux-gnu/countryfetch --version countryfetch 0.1.9
そのまま実行するとgeoipから実行した場所の国の情報を表示しようとします.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Japan @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ------- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Area: 377,930 km² (145,900 miles²) @@@@@@@@@@@@@@@@#OznnzO#@@@@@@@@@@@@@@@@ Continent: Asia @@@@@@@@@@@@@@k/++++++++/k@@@@@@@@@@@@@@ Population: 125,836,021 People @@@@@@@@@@@@@U++++++++++++U@@@@@@@@@@@@@ Neighbours: No neighbours @@@@@@@@@@@@Z++++++++++++++Z@@@@@@@@@@@@ Capital: Tokyo @@@@@@@@@@@@1++++++++++++++)@@@@@@@@@@@@ ISO Codes: JP / JPN @@@@@@@@@@@@_++++++++++++++_@@@@@@@@@@@@ Driving side: left @@@@@@@@@@@@(++++++++++++++(@@@@@@@@@@@@ Dialing code: +81 @@@@@@@@@@@@q++++++++++++++q@@@@@@@@@@@@ Language: Japanese @@@@@@@@@@@@@Q_++++++++++_Q@@@@@@@@@@@@@ Established: February 11, 660 BC @@@@@@@@@@@@@@oj_++++++_jo@@@@@@@@@@@@@@ Currency: ¥ JPY (Japanese yen) @@@@@@@@@@@@@@@@&qJXXJq&@@@@@@@@@@@@@@@@ Top Level Domains: .jp, .みんな @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ███████████████████████████ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
geoipは ip-api.com を利用しているようです.
$ grep http ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/countryfetch-0.1.9/src/location.rs "http://ip-api.com/json/{ip}?fields=status,message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,offset,currency,isp,org,as,asname,reverse,mobile,proxy,hosting,query" $ curl -s http://ip-api.com/json/`curl -s ifconfig.me/ip`?fields=status,country | jq . │ │{ │ │ "status": "success", │ │ "country": "Japan" │ │} $ curl -s http://ip-api.com/json/`torify curl -s ifconfig.me/ip`?fields=status,country | jq . │ │{ │ │ "status": "success", │ │ "country": "Ukraine" │ │}
特定の国を表示したい場合は後ろに国名を付けます.
$ countryfetch-x86_64-unknown-linux-gnu/countryfetch-x86_64-unknown-linux-gnu/countryfetch UnitedKingdom
/Z%@8C];;;;;;;;;\@]]]]@\;;;;;;;;;]YQt}zo United Kingdom Q(}YM@@d\I;;;;;;\@]]]]@\;;;;;;I\ZU}(0%@$ ------- ~c0x[xd$@#c<;;;;\@]]]]@\;;;;~c0x[xd$@Mc~ Area: 242,900 km² (93,800 miles²) ;;I\ZY}(0%@BO[;;\@]]]]@\;;[QQ(}YM@@b\I;; Continent: Europe ;;;;;]UQ/}zo@@kjf@]]]]@fj0z}/Z%@8C];;;;; Population: 67,215,293 People rrrrrrrv*aYXwB@@$@]]]]@BwXYa@@@*vrrrrrrr Neighbour: Ireland aaaaaaaaaaaaaaaaaa]]]]aaaaaaaaaaaaaaaaaa Capital: London ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] ISO Codes: GB / GBR ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] Driving side: left ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] Dialing code: +44 WWWWWWWWWWWWWWWWWW]]]]WWWWWWWWWWWWWWWWWW Language: English |||||||x*@@$qunw8@]]]]@%@@Bwnuqox||||||| Established: January 1, 1801 ;;;;I(m$@WC))JC(/@]]]]@/(m$@WC))JL(I;;;; Currency: £ GBP (British pound) ;;!n#@@au]fZX~;;\@]]]]@\;;+U8@$qt]umn!;; Top Level Domain: .uk ]C8@%Z/}zQj!;;;;\@]]]]@\;;;;!jk@@oz}/QU] @@MY}(QL[;;;;;;;\@]]]]@\;;;;;;;[O$@%0(}Y ███████████████████████████ au]fZX~;;;;;;;;;\@]]]]@\;;;;;;;;;~Y8@$qt
国コードでも良さそう.
$ countryfetch-x86_64-unknown-linux-gnu/countryfetch-x86_64-unknown-linux-gnu/countryfetch de
Germany ------- Area: 357,114 km² (137,900 miles²) Continent: Europe Population: 83,240,525 People ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Neighbours: Austria, Belgium, {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ Czechia, Denmark, France, Luxembourg, {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ Netherlands, Poland, Switzerland {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ Capital: Berlin {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ ISO Codes: DE / DEU {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ Driving side: right kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk Dialing code: +49 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Language: German @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Established: October 3, 1990 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Currency: EUR € (Euro) @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Top Level Domain: .de @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
国は250登録されているようです.
$ countryfetch-x86_64-unknown-linux-gnu/countryfetch-x86_64-unknown-linux-gnu/countryfetch --list-countries | grep "[^${control_characters} -~]" | wc -l 250
すべての国を表示してみたり.
250も旗を用意するの大変そうもしかして絵文字から変換したりしてる?とか思いましたが gen_country/src/lib.rs にAAの旗を含めハードコードされているようです.
https://github.com/nik-rev/countryfetch/blob/main/gen_country/src/lib.rs