From ba17712ad9ae3bd1d695bb3ab32df6ca9fba79aa Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 27 Jun 2011 23:21:25 +0200 Subject: db-ris: Add --help and --version options --- bin/db-ris | 65 ++++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/bin/db-ris b/bin/db-ris index f3e3beb..debbe0e 100755 --- a/bin/db-ris +++ b/bin/db-ris @@ -5,7 +5,7 @@ use 5.010; our $VERSION = '0.0'; -use Getopt::Long; +use Getopt::Long qw(:config no_ignore_case); use List::Util qw(first max); use Travel::Status::DE::DeutscheBahn; @@ -18,11 +18,14 @@ my @output; binmode( STDOUT, ':encoding(utf-8)' ); GetOptions( - 'd|date=s' => \$date, - 'v|via=s' => \$filter_via, - 'm|mot=s' => \$types, - 't|time=s' => \$time, -); + 'd|date=s' => \$date, + 'h|help' => sub { show_help(0) }, + 'm|mot=s' => \$types, + 't|time=s' => \$time, + 'v|via=s' => \$filter_via, + 'V|version' => \&show_version, + +) or show_help(1); for my $type ( split( qr{,}, $types ) ) { if ( substr( $type, 0, 1 ) eq q{!} ) { @@ -40,6 +43,22 @@ my $status = Travel::Status::DE::DeutscheBahn->new( time => $time, ); +sub show_help { + my ($code) = @_; + + print 'Usage: db-ris [-d ] [-m ] [-t