summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/efa-m71
1 files changed, 51 insertions, 20 deletions
diff --git a/bin/efa-m b/bin/efa-m
index 66694c6..dfa6ef7 100755
--- a/bin/efa-m
+++ b/bin/efa-m
@@ -11,14 +11,14 @@ use Getopt::Long qw(:config no_ignore_case);
use List::Util qw(max);
use Travel::Status::DE::VRR;
-my ( $date, $time, $input_type );
+my ( $date, $time, $input_type, $list_lines );
my ( @grep_lines, @grep_platforms );
-my @output;
GetOptions(
'd|date=s' => \$date,
'h|help' => sub { show_help(0) },
'l|line=s@' => \@grep_lines,
+ 'L|linelist' => \$list_lines,
'p|platform=s@' => \@grep_platforms,
't|time=s' => \$time,
'V|version' => \&show_version,
@@ -98,33 +98,64 @@ sub display_result {
return;
}
-if ( my $err = $status->errstr ) {
- say STDERR "Request error: ${err}";
- exit 2;
-}
+sub show_lines {
+ my @output;
-for my $d ( $status->results ) {
+ for my $l ( $status->lines ) {
- my $platform = $d->platform;
+ if ( @grep_lines and not( $l->name ~~ \@grep_lines ) ) {
+ next;
+ }
- if ( $d->platform_db ) {
- $platform .= ' (DB)';
+ push( @output,
+ [ $l->type, $l->name, $l->direction // q{}, $l->route // q{} ] );
}
- if (
- ( @grep_lines and not( $d->line ~~ \@grep_lines ) )
- or ( @grep_platforms
- and not( $platform ~~ \@grep_platforms ) )
- )
- {
- next;
+ display_result(@output);
+
+ return;
+}
+
+sub show_results {
+ my @output;
+
+ for my $d ( $status->results ) {
+
+ my $platform = $d->platform;
+
+ if ( $d->platform_db ) {
+ $platform .= ' (DB)';
+ }
+
+ if (
+ ( @grep_lines and not( $d->line ~~ \@grep_lines ) )
+ or ( @grep_platforms
+ and not( $platform ~~ \@grep_platforms ) )
+ )
+ {
+ next;
+ }
+
+ push( @output,
+ [ $d->time, $platform, $d->line, $d->destination, $d->info ] );
}
- push( @output,
- [ $d->time, $platform, $d->line, $d->destination, $d->info ] );
+ display_result(@output);
+
+ return;
+}
+
+if ( my $err = $status->errstr ) {
+ say STDERR "Request error: ${err}";
+ exit 2;
}
-display_result(@output);
+if ($list_lines) {
+ show_lines();
+}
+else {
+ show_results();
+}
__END__