summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-02-27 17:44:05 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2010-02-27 17:44:05 +0100
commitccdb63ba4036f849d47dc561904d01241ad06b7a (patch)
tree27fde4693c1ef1bb9f78e0ae97ea682c7e1fc8b7 /bin
parent174b56b763636960e4e55b91791eafadaf93225f (diff)
Add argument verification for --date & --time; die upon invalid arguments
Diffstat (limited to 'bin')
-rwxr-xr-xbin/efa14
1 files changed, 10 insertions, 4 deletions
diff --git a/bin/efa b/bin/efa
index 2736c7c..3d58063 100755
--- a/bin/efa
+++ b/bin/efa
@@ -264,7 +264,7 @@ if (@via == 2) {
foreach my $type ($from_type, $to_type, $via_type) {
if (not ($type ~~ ['stop', 'address', 'poi'])) {
$type = 'stop';
- warn("from/to/via type: Must be stop, address or poi, not '$type'\n");
+ die("from/to/via type: Must be stop, address or poi, not '$type'\n");
}
}
@@ -282,9 +282,15 @@ elsif ($time_depart) {
}
if ($time) {
+ if ($time !~ /^ [0-2]? \d : [0-5]? \d $/x) {
+ die("Invalid argument. Usage: --time HH:MM\n");
+ }
@post{'itdTimeHour', 'itdTimeMinute'} = split(/:/, $time);
}
if ($date) {
+ if ($date !~ /^ [0-3]? \d \. [01]? \d (?: \. \d{4} )? /x) {
+ die("Invalid argument: Usage: --date DD.MM[.YYYY]\n");
+ }
@post{'itdDateDay', 'itdDateMonth', 'itdDateYear'} = split(/\./, $date);
$post{itdDateYear} //= (localtime(time))[5] + 1900;
}
@@ -314,7 +320,7 @@ if ($prefer) {
when ('nowait') { $post{routeType} = 'LEASTINTERCHANGE' }
when ('nowalk') { $post{routeType} = 'LEASTWALKING' }
default {
- warn("--prefer usage: speed / nowait / nowalk\n");
+ die("Invalid argument. Usage: --prefer speed|nowait|nowalk\n");
}
}
}
@@ -330,7 +336,7 @@ if ($include) {
when ('ice') { $post{lineRestriction} = 400 }
when (/\d+/) { $post{lineRestriction} = $include }
default {
- warn("--include usage: local / ic / ice\n");
+ die("Invalid argument. Usage: --include local|ic|ice\n");
}
}
}
@@ -340,7 +346,7 @@ if ($walk_speed) {
$post{changeSpeed} = $walk_speed;
}
else {
- warn("--walk-speed usage: normal / fast / slow\n");
+ die("Invalid argument. Uaseg: --walk-speed normal|fast|slow\n");
}
}