diff options
| author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-11-30 18:33:04 +0100 |
|---|---|---|
| committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-11-30 18:33:04 +0100 |
| commit | 986d3384b69a7df3070795a6433507bcdfa55846 (patch) | |
| tree | a93e4d4573c5f1289fa974d1ac885850c106dc6f | |
| parent | 041239ed08399f6c87d3e33f49ff2216a0ff5232 (diff) | |
dbris-m: Add -Or (== -Oa for efa-m compat) option to display via stops
| -rwxr-xr-x | bin/dbris-m | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/bin/dbris-m b/bin/dbris-m index a98eab5..c87bfb0 100755 --- a/bin/dbris-m +++ b/bin/dbris-m @@ -9,7 +9,7 @@ use utf8; use DateTime; use Encode qw(decode); use JSON; -use Getopt::Long qw(:config no_ignore_case); +use Getopt::Long qw(:config no_ignore_case bundling); use List::Util qw(min max); use Travel::Status::DE::DBRIS; @@ -21,6 +21,8 @@ my $use_cache = 1; my $cache; my $use_colour = 'auto'; my ( $json_output, $raw_json_output, $with_polyline ); +my @output_args; +my %show_output; my %known_mot = map { $_ => 1 } (qw(ICE EC_IC IR REGIONAL SBAHN BUS SCHIFF UBAHN TRAM ANRUFPFLICHTIG)); @@ -43,6 +45,7 @@ GetOptions( 'h|help' => sub { show_help(0) }, 'j|with-jid' => \$show_jid, 'm|modes-of-transit=s' => \$mots, + 'O|output=s@' => \@output_args, 't|time=s' => \$time, 'V|version' => \&show_version, 'cache!' => \$use_cache, @@ -85,6 +88,15 @@ if ( not $station ) { show_help(1); } +# Support for --output=arg1,arg2 +for my $field ( split( qr{,}, join( q{,}, @output_args ) ) ) { + if ( $field eq 'a' ) { $show_output{route_after} = 1 } + elsif ( $field eq 'r' ) { $show_output{route} = 1 } + else { + $show_output{$field} = 1; + } +} + my %opt = ( cache => $cache, station => $station, @@ -358,6 +370,13 @@ if ( $opt{station} ) { if ($show_jid) { say $result->id =~ s{ }{}gr; } + if ( $show_output{route} or $show_output{route_after} ) { + my @via = $result->via; + if ( @via and $via[-1] eq $result->destination ) { + pop(@via); + } + printf( " via %s\n", join( q{ ยท }, @via ) ); + } for my $message ( $result->messages ) { say $message->{text}; } |
