Giter VIP home page Giter VIP logo

elastio_rust_test_weather's Introduction

elastio_rust_test_weather

Test Task for a job submission to Elastio

Usage

weather configure <provider_name> # Set a new provider in a config file
cargo run -- configure <provider_name> # While developing
weather get <address> [date="now"] # Get weather forecast (or historical data) (and potentially current weather conditions) for requested address and time
cargo run -- get <address> [date="now"] # While developing

Example

With open_meteo provider

Weather in Groningen, Netherlands on 2023-02-24

cargo run -- get "Groningen, Netherlands" "2023-02-24"

Weather in Kyiv, Ukraine, current date

cargo run -- get "Kyiv, Ukraine"

With met_no provider

Weather in Groningen, Netherlands, current date

cargo run -- get "Groningen, Netherlands"

Weather in Kyiv, Ukraine, current date

cargo run -- get "Kyiv, Ukraine"

FAQ:

Q: Which providers are available?
A: open_meteo (supports current conditions, forecast & history data, custom dates) & met_no (only forecast, no custom dates)

Q: Why only 2 providers and why specifically those 2?
A: They are free and don't require giving my bank account information to get an API key. I'm also not familiar with best practices of storing secret API key in a public repo, so I didn't want to risk it. To answer why there is only 2 of them and not more: It's very hard to find a completely free API that provides all the needed data for ideal experience with the app, so I decided to go with the minimum.

Q: Is there a config file for the app?
A: Yes, it should be created automatically on the first run with "open_meteo" as the default provider located in "{config_dir}/weather/config.json" (Check https://docs.rs/dirs/latest/dirs/fn.config_dir.html)

Q: What are the acceptable values for the address?
A: Address can either be an actual address written in English or a "{lat},{lon}" pair, I use geocoding crate under the hood to get the lat,long from address and address from lon,lat (api requirement) for ui display

Q: What are the acceptable values for the date?
A: Date can be either "now" or a date in the format, supported by dateparser

Q: How do you parse the cli args?
A: I use clap crate for that and utilize its builder API

Q What do you use to draw the data on the screen?
A: I use tui-rs crate for that

Q: UI is weird/ugly, why?
A: I'm not a designer, have a limited tui-rs experience and the library itself is quite limited on customization front, that's the best I can do with it in this short amount of time. I also had to modify tui-rs BarChart to accept and draw negative floating point values, it was a quick fix, the math is not perfect, but it gets the job done.

Q: What is this weird built dependency you have and why do you use it?
A: It's a crate that allows you to get the build info for the app and I use it to accurately create the config dir based on the name of the package (which in the long run can reduce the headache of having to replace the name in multiple places/files in case I decide to rename the package if I want to continue working on it)

Q: Why no test cases?
A: I'm not new to cargos unit testing framework, but I'm still not very efficient with writing appropriate test cases and I just didn't want to spend too much time dealing with it. + I tested the application myself with different inputs, and it worked as expected, if the arguments were correct, and shown right errors when they weren't. It is definitely possible that I could've missed something, but as I said, I didn't want to spend too much time testing a relatively simple CLI tool, which is suppoed to just be a prototype anyway.

elastio_rust_test_weather's People

Contributors

tukanoidd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.