print ("Lifts from %s to %s on %d.%d.%d\n", city_from, city_to,
date.get_day (), date.get_month (), date.get_year ());
- var lift_list = yield adac.get_lift_list (city_from, city_to, date);
+ var lift_list = yield adac.get_lift_list (city_from, 0, city_to, 0, date);
foreach (Lift lift in lift_list) {
- print ("%s\t%s\t%s\t%s\t%d\t%s\t", lift.city_from, lift.city_to, lift.date, lift.time, lift.places, lift.price);
+ string datetime = "%02d.%02d.%02d".printf (lift.time.day, lift.time.month, lift.time.year);
+ if (lift.time.hour >= 0)
+ datetime += ", %d:%02d".printf (lift.time.hour, lift.time.minute);
+ print ("%s\t%s\t%s\t%d\t%s\t", lift.city_from, lift.city_to, datetime, lift.places, lift.price);
if (LiftFlags.SMOKER in lift.flags)
print ("smoker ");
else if (LiftFlags.NON_SMOKER in lift.flags)
lift.href = href;
yield adac.update_lift_details (lift);
- print ("%s\t%s\t%s\t%s\t%d\t%s\t", lift.city_from, lift.city_to, lift.date, lift.time, lift.places, lift.price);
+ string datetime = "%02d.%02d.%02d".printf (lift.time.day, lift.time.month, lift.time.year);
+ if (lift.time.hour >= 0)
+ datetime += ", %d:%02d".printf (lift.time.hour, lift.time.minute);
+ print ("%s\t%s\t%s\t%d\t%s\t", lift.city_from, lift.city_to, datetime, lift.places, lift.price);
if (LiftFlags.SMOKER in lift.flags)
print ("smoker ");
else if (LiftFlags.NON_SMOKER in lift.flags)
print ("\tvia %s\n", via);
}
- print ("Driver: %s (%s)\n", lift.name, lift.phone);
+ string phone;
+ if (lift.cell != null)
+ phone = lift.cell;
+ else if (lift.phone != null)
+ phone = lift.phone;
+ else if (lift.phone2 == null)
+ phone = lift.phone2;
+ else
+ phone = "";
+ print ("Driver: %s (%s)\n", lift.name, phone);
print ("Description:\n%s\n", lift.description);
loop.quit ();
}
+void usage () {
+ print ("usage: beifahrer-cli <city_from> <city_to> [date]\n");
+ print ("or: beifahrer-cli details <lift_url>\n");
+ print ("or: beifahrer-cli login <username> <password>\n");
+ print ("or: beifahrer-cli login <cookie>\n");
+}
+
static int main (string[] args) {
loop = new MainLoop (null);
if (args.length < 3) {
- print ("usage: beifahrer-cli <city_from> <city_to> [date]\n");
- print ("or: beifahrer-cli details <lift_url>\n");
+ usage ();
return 1;
}
+ Curl.global_init (Curl.GLOBAL_DEFAULT);
+
adac = new AdacMitfahrclub ();
+ if (args[1] == "login") {
+ if (args.length > 3) {
+ adac.login (args[2], args[3]);
+ } else {
+ adac.set_cookie (args[2]);
+ adac.login (null, null);
+ }
+ loop.run ();
+ return 0;
+ }
+
if (args[1] == "details") {
get_details.begin (args[2]);
get_lifts.begin (city_from, city_to, date);
loop.run ();
+
+ Curl.global_cleanup ();
+
return 0;
}