summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 6bac375..356db21 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -34,6 +34,7 @@ enum Command {
Destination {
to: String
},
+ Arewethereyet,
/// If iceportal.de is available, ask it which train we're in and
/// check in
Autocheckin,
@@ -92,6 +93,28 @@ fn main() -> Result<(), ureq::Error> {
println!("{}: {}", traveltext, status);
}
+ Command::Arewethereyet => {
+ let status: Status = exiting_get_request(
+ &format!("{}/api/v1/status/{}", cli.baseurl, config.token_status),
+ cli.debug,
+ );
+
+ match status.to_station {
+ None => println!("{}: Fahrt ins {}", traveltext, "Blaue".blue()),
+ Some(to) => {
+ let now = chrono::Utc::now();
+ let duration = to.real_arrival().map(|dt| *dt - now);
+ match duration {
+ Some (d) => println!(
+ "{}: we'll be there in {} minutes",
+ traveltext,
+ d.num_minutes()
+ ),
+ None => println!("{}: I have no idea", traveltext)
+ }
+ }
+ }
+ },
Command::Checkin { from, to, train } => {
let resp: Response = exiting_post_request(
&format!("{}/api/v1/travel", cli.baseurl),