summaryrefslogtreecommitdiff
path: root/bin/hafas
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-04-01 18:23:51 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-04-01 18:25:58 +0200
commite6480f632d07b30f4f3ee538731f157c922a16b2 (patch)
tree3a0cd88a631efc74d82c6a21368bcd7070c09b06 /bin/hafas
parent452e421c7f457e422860e75146d97fb3673221e2 (diff)
add -x / --exclude-infeasible option
Diffstat (limited to 'bin/hafas')
-rwxr-xr-xbin/hafas43
1 files changed, 27 insertions, 16 deletions
diff --git a/bin/hafas b/bin/hafas
index 3838373..2a3aed5 100755
--- a/bin/hafas
+++ b/bin/hafas
@@ -20,6 +20,7 @@ my $types = q{};
my $developer_mode;
my ( $json_output, $raw_json_output );
my $show_full_route;
+my $exclude_infeasible;
my ( $list_services, $service );
my ( @excluded_mots, @exclusive_mots );
my $max_change = undef;
@@ -46,22 +47,23 @@ my $output_bold = -t STDOUT ? "\033[1m" : q{};
my $output_reset = -t STDOUT ? "\033[0m" : q{};
GetOptions(
- 'a|arrive=s' => sub { $arrival = 1; $time = $_[1] },
- 'c|max-change=s' => \$max_change,
- 'C|change-time=s' => \$min_change_time,
- 'd|date=s' => \$date,
- 'h|help' => sub { show_help(0) },
- 'f|full-route' => \$show_full_route,
- 'l|language=s' => \$language,
- 'm|mot=s' => \$types,
- 's|service=s' => \$service,
- 't|time|depart=s' => \$time,
- 'v|verbose+' => \$verbosity,
- 'V|version' => \&show_version,
- 'devmode' => \$developer_mode,
- 'json' => \$json_output,
- 'raw-json' => \$raw_json_output,
- 'list' => \$list_services,
+ 'a|arrive=s' => sub { $arrival = 1; $time = $_[1] },
+ 'c|max-change=s' => \$max_change,
+ 'C|change-time=s' => \$min_change_time,
+ 'd|date=s' => \$date,
+ 'h|help' => sub { show_help(0) },
+ 'f|full-route' => \$show_full_route,
+ 'l|language=s' => \$language,
+ 'm|mot=s' => \$types,
+ 's|service=s' => \$service,
+ 't|time|depart=s' => \$time,
+ 'x|exclude-infeasible' => \$exclude_infeasible,
+ 'v|verbose+' => \$verbosity,
+ 'V|version' => \&show_version,
+ 'devmode' => \$developer_mode,
+ 'json' => \$json_output,
+ 'raw-json' => \$raw_json_output,
+ 'list' => \$list_services,
) or show_help(1);
@@ -338,6 +340,9 @@ for my $res ( $hafas->connections ) {
}
if ( $cancelled or $negative_transfer or $part_cancelled ) {
+ if ($exclude_infeasible) {
+ next;
+ }
printf(
"%s (%02d:%02d) %s %s %s\n",
$res->dep->strftime('XX.XX. %H:%M'),
@@ -538,6 +543,12 @@ B<-v>) to 3 (B<-vvv>).
Show version information and exit.
+=item B<-x>, B<--exclude-infeasible>
+
+HAFAS responses include journeys that are infeasible e.g. due to delayed or
+cancelled trips. By default, B<hafas> displays those with an XX.XX. departure
+date. When this option is set, B<hafas> silently ignores them instead.
+
=back
=head1 EXIT STATUS