Last active
July 10, 2022 08:58
-
-
Save sergiosouzalima/59485fe21602c583b7d772774eb41636 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Program name........: wttrin_weather_lib.nim | |
## Program description.: Testing Nim library that fetches weather from wttr.in | |
## Author..............: Sergio Lima | |
## Created on..........: Jul, 9 2022 | |
## Install lib | |
## $ nimble install wttrin -y | |
## How to compile | |
## $ nim c -d:ssl wttrin_weather_lib.nim | |
## How to run | |
## $ ./wttrin_weather_lib | |
import wttrin | |
import std/strformat | |
const citiesTuple = ( | |
saopaulo: "Sao Paulo-SP", | |
maringa: "Maringa-PR", | |
fortaleza: "Fortaleza-CE", | |
manaus: "Manaus-AM") | |
proc getWeather(city: string): (string, string, string) = | |
return ($getTemp(city), $getUnit(city), getCondition(city)) | |
for city, cityName in citiesTuple.fieldPairs: | |
let (temp, unit, cond) = getWeather(city) | |
echo cityName & fmt""" {temp}{unit} {cond}""" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment