summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 9bb2f9e..f41d871 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -32,9 +32,14 @@ enum Command {
train: TrainRef
},
/// (If already checked in) change the trip's destination
- Destination {
+ To {
to: String
},
+ /// (If already checked in) change the trip's starting point,
+ /// Warning: may lead to doubled entries in your trip history!
+ From {
+ from: String
+ },
Station {
station: String
},
@@ -146,7 +151,33 @@ fn main() -> Result<(), ureq::Error> {
println!("{}: {}", traveltext, resp);
}
- Command::Destination { to } => {
+ Command::From { from } => {
+ println!("{}: {}", traveltext, "warning: this command may pollute your trip history".red());
+ let status: Status = exiting_get_request(
+ &format!("{}/api/v1/status/{}", cli.baseurl, config.token_status),
+ cli.debug
+ );
+ match status.train {
+ Some(train) => {
+ let resp: Response = exiting_post_request(
+ &format!("{}/api/v1/travel", cli.baseurl),
+ Action::CheckIn {
+ train: train.into(),
+ to_station: status.to_station.map(|s| s.ds100),
+ token: config.token_travel,
+ comment: None,
+ from_station: from
+ },
+ cli.debug
+ );
+ println!("{}: {}", traveltext, resp);
+ }
+ None => {
+ println!("{}: {}", traveltext, "not checked in?".red())
+ }
+ }
+ }
+ Command::To { to } => {
let resp: Response = exiting_post_request(
&format!("{}/api/v1/travel", cli.baseurl),
Action::CheckOut {