Write a realization for weather conditions monitoring using OpenWeatherMap API and components from Boost library.
The program is divided into 3 modules:
network- is responsible for connecting to the external server, sending a request, and receiving a response.client- is responsible for passing data tonetwork, processing results from it, and printing results on a screen.application- is responsible for processing command-line arguments and passing them toclient.
The program must be capable of:
- Showing help (as shown in
application.hpp), if no arguments present or it was-hor--helpargument; - Reading city from the console;
- Reading token from console (If not present, check the file
token.txtin the same directory as executable). Remember, token - is your secret information. - Showing information about the weather in specified city. (as shown in
application.hpp):- Name of the city
- Temperature (degree Celsius)
- Wind velocity (meters per second)
- Wind direction (degrees)
- Connection to the server:
- Reading host -
api.openweathermap.org(must be set as default) - Reading port -
80(must be set as default)
- Reading host -
- Correct behavior when it can't connect to the server:
- Prints
"Can't reach server"when a connection could not be established - Prints
"Can't get weather in %city_name%"when a city does not exist - Does not terminate with a non-zero error code in other cases
- Prints
For header files, only appending is allowed.
main.cpp is forbidden for modification.
Must use Boost.Asio and Boost.Beast to work with the network, and Boost.Program to handle command-line arguments.
Must use CMake to build the application. Name of the program must be Weather.
.gitlab-ci.yml is forbidden for modification.
- Open the following site: https://home.openweathermap.org/users/sign_up
- Sing up there
- In the purpose field select "Education/science"
- Check your email, open letter, and press "Verify"
- Your API will be here: https://home.openweathermap.org/api_keys
- Read the API doc: https://openweathermap.org/current
- Go to Settings -> CI/CD -> General pipelines
- Set CI/CD configuration file as
Weather/.gitlab-ci.yml - Manually triger new pipeline (once only, later it will be triggered automatically)
- Go to CI/CD -> Pipelines -> Run Pipeline (Blue button on top)
- Select branch with your solution
- Start it
- Pipeline passes
- Shows help
- Can read city from a console
- Can read token from a console
- Can read token from a file
- Prints weather in existing city
- Uses default address and port, can select other address and port
- Prints correct message when a connection could not be established
- Prints correct message when a city does not exist
- Always finishes with exit code 0
Technologies used:
- CMake for building
- boost::asio
- boost::beast
- boost::program
Style:
- No raw pointers used and no potential memory leaks exist
- Potential errors are wrapped in try-catch
- Header guards are present
Task requirements:
- Only additions are present in header files
- create build directory
- put "cmake ../src && make" in command line to build project
- put "./Weather" to run