diff options
author | Daniel Friesel <derf@finalrewind.org> | 2013-12-24 16:10:52 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2013-12-24 16:10:52 +0100 |
commit | 8a07867b705e81db248e6fab4f75e9d2b0315f1e (patch) | |
tree | 8d0c8424551ad7feed45ea8f72487a049354e064 /bin/aseag-m | |
parent | 233d24483e7be77e85893fdceafb6f508788fbdf (diff) |
Remove fuzzy matching from API, add get_stop_by_name instead
Diffstat (limited to 'bin/aseag-m')
-rwxr-xr-x | bin/aseag-m | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/bin/aseag-m b/bin/aseag-m index 52cd946..40f8898 100755 --- a/bin/aseag-m +++ b/bin/aseag-m @@ -94,6 +94,26 @@ sub display_result { return; } +sub get_exact_stop_name { + my ($fuzzy_name) = @_; + + my @stops = $status->get_stop_by_name($fuzzy_name); + + if ( @stops == 0 ) { + say STDERR "No stops match '$fuzzy_name'"; + exit(1); + } + elsif ( @stops == 1 ) { + return $stops[0]; + } + else { + say STDERR "The stop '$fuzzy_name' is ambiguous. Please choose one " + . 'of the following:'; + say STDERR join( "\n", @stops ); + exit(1); + } +} + sub show_results { my @output; @@ -169,6 +189,10 @@ if ( my $err = $status->errstr ) { exit 2; } +$stop_name = get_exact_stop_name($stop_name); +if ($via) { + $via = get_exact_stop_name($via); +} show_results(); __END__ |