summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs23
-rw-r--r--src/types.rs2
2 files changed, 24 insertions, 1 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),
diff --git a/src/types.rs b/src/types.rs
index 2e4d2e1..f4947e2 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -124,7 +124,7 @@ pub struct Status {
checked_in: bool,
from_station: Station,
#[serde(deserialize_with = "parse_optional_station")]
- to_station: Option<Station>,
+ pub to_station: Option<Station>,
intermediate_stops: Vec<Stop>,
train: Option<Train>,
action_time: u64,