projects
/
beifahrer
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Debian packaging: 0.0.4-1
[beifahrer]
/
src
/
beifahrer-cli.vala
diff --git
a/src/beifahrer-cli.vala
b/src/beifahrer-cli.vala
index
74ad7c0
..
5ee78c8
100644
(file)
--- a/
src/beifahrer-cli.vala
+++ b/
src/beifahrer-cli.vala
@@
-23,7
+23,7
@@
async void get_lifts (string city_from, string city_to, Date date) {
print ("Lifts from %s to %s on %d.%d.%d\n", city_from, city_to,
date.get_day (), date.get_month (), date.get_year ());
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) {
string datetime = "%02d.%02d.%02d".printf (lift.time.day, lift.time.month, lift.time.year);
if (lift.time.hour >= 0)
foreach (Lift lift in lift_list) {
string datetime = "%02d.%02d.%02d".printf (lift.time.day, lift.time.month, lift.time.year);
if (lift.time.hour >= 0)
@@
-66,23
+66,51
@@
async void get_details (string href) {
print ("\tvia %s\n", via);
}
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 ();
}
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) {
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;
}
return 1;
}
+ Curl.global_init (Curl.GLOBAL_DEFAULT);
+
adac = new AdacMitfahrclub ();
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]);
if (args[1] == "details") {
get_details.begin (args[2]);
@@
-104,5
+132,8
@@
static int main (string[] args) {
get_lifts.begin (city_from, city_to, date);
loop.run ();
get_lifts.begin (city_from, city_to, date);
loop.run ();
+
+ Curl.global_cleanup ();
+
return 0;
}
return 0;
}