From bac92f915ff58055e9c22337a7eb0f64fa03c440 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Wed, 29 May 2024 19:36:29 +0200 Subject: hafas-m: add -n / --num-results option --- bin/hafas-m | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'bin') diff --git a/bin/hafas-m b/bin/hafas-m index ea8471f..43ad111 100755 --- a/bin/hafas-m +++ b/bin/hafas-m @@ -17,7 +17,8 @@ use Travel::Status::DE::HAFAS; my ( $date, $time, $language ); my $arrivals; my $show_jid; -my $types = q{}; +my $num_results = 30; +my $types = q{}; my $developer_mode; my $via; my ( $json_output, $raw_json_output ); @@ -35,20 +36,21 @@ my $output_bold = -t STDOUT ? "\033[1m" : q{}; my $output_reset = -t STDOUT ? "\033[0m" : q{}; GetOptions( - 'a|arrivals' => \$arrivals, - 'd|date=s' => \$date, - 'h|help' => sub { show_help(0) }, - 'j|with-jid' => \$show_jid, - 'l|language=s' => \$language, - 'm|mot=s' => \$types, - 's|service=s' => \$service, - 't|time=s' => \$time, - 'v|via=s' => \$via, - 'V|version' => \&show_version, - 'devmode' => \$developer_mode, - 'json' => \$json_output, - 'raw-json' => \$raw_json_output, - 'list' => \$list_services, + 'a|arrivals' => \$arrivals, + 'd|date=s' => \$date, + 'h|help' => sub { show_help(0) }, + 'j|with-jid' => \$show_jid, + 'l|language=s' => \$language, + 'm|mot=s' => \$types, + 'n|num-results=s' => \$num_results, + 's|service=s' => \$service, + 't|time=s' => \$time, + 'v|via=s' => \$via, + 'V|version' => \&show_version, + 'devmode' => \$developer_mode, + 'json' => \$json_output, + 'raw-json' => \$raw_json_output, + 'list' => \$list_services, ) or show_help(1); @@ -79,6 +81,7 @@ my %opt = ( developer_mode => $developer_mode, service => $service, language => $language, + results => $num_results, ); if ( $opt{station} =~ m{ ^ (? [0-9.]+ ) : (? [0-9].+ ) $ }x ) { @@ -785,6 +788,10 @@ To show them exclusively, set I to I,I,... The I types depend on the used service. Use C<< -m help >> to list them. +=item B<-n>, B<--num-results> I + +Request up to I results. Default: 30. + =item B<--raw-json> Print unprocessed HAFAS response as JSON and exit. -- cgit v1.2.3