diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-01-20 21:21:04 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-01-20 21:21:04 +0100 |
commit | 0c5496f0361916f2c5eec807863cf0966cad88c4 (patch) | |
tree | d7608e5166a511b75fd7fa8c677ac80e2a4a926d /bin/dbris | |
parent | f1e494c932f24272f1addb5611a9ccc81ac50de9 (diff) |
fine-grained specification of passengers and discounts
Diffstat (limited to 'bin/dbris')
-rwxr-xr-x | bin/dbris | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -16,7 +16,7 @@ use Travel::Routing::DE::DBRIS; my ( $date, $time, $from, $to, $language ); my $mots; -my ( $first_class, $discounts ); +my ( $first_class, $passengers ); my $developer_mode; my ( $json_output, $raw_json_output ); my $use_cache = 1; @@ -36,12 +36,12 @@ my $output_reset = -t STDOUT ? "\033[0m" : q{}; GetOptions( 'd|date=s' => \$date, - 'D|discounts=s' => \$discounts, 'h|help' => sub { show_help(0) }, 'f|full-route' => \$show_full_route, 'first-class!' => \$first_class, 'm|modes-of-transit=s' => \$mots, 'l|language=s' => \$language, + 'p|passengers=s' => \$passengers, 't|time=s' => \$time, 'V|version' => \&show_version, 'cache!' => \$use_cache, @@ -177,8 +177,18 @@ if ($mots) { $opt{modes_of_transit} = [ grep { $known_mot{$_} } @mots ]; } -if ($discounts) { - $opt{discounts} = [ split( qr{, *}, $discounts ) ]; +if ($passengers) { + for my $passenger ( split( qr{; *}, $passengers ) ) { + my ( $type, $discounts ) = split( qr{ *: *}, $passenger ); + $discounts = $discounts ? [ split( qr{, *}, $discounts ) ] : []; + push( + @{ $opt{passengers} }, + { + type => $type, + discounts => $discounts, + } + ); + } } sub show_help { @@ -293,7 +303,7 @@ for my $connection ( $ris->connections ) { $connection->duration->in_units( 'hours', 'minutes' ), $connection->arr ? $connection->arr->strftime('%H:%M') : q{??:??}, format_occupancy($connection), - defined $connection->price + ( defined $passengers and defined $connection->price ) ? sprintf( ' %.2f %s', $connection->price, $connection->price_unit ) : q{}, $header, |