-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
30 lines (24 loc) · 760 Bytes
/
main.cpp
File metadata and controls
30 lines (24 loc) · 760 Bytes
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
#include <iostream>
#include "WeatherClient.h"
#include "EnvLoader.h"
int main() {
try {
EnvLoader env_loader(".env");
auto env_vars = env_loader.load();
std::string api_key = env_vars["API_KEY"];
if (api_key.empty()) {
std::cerr << "API_KEY is not set in the .env file" << std::endl;
return 1;
}
std::string location;
std::cout << "Name of the city: ";
std::getline(std::cin, location);
WeatherClient client(api_key);
std::string weather_info = client.getWeather(location);
std::cout << weather_info << std::endl;
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
}