From 329134383358e3a64a342cf02efe505a8f9b9425 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 29 Jun 2011 03:01:33 +0200 Subject: efa: Show help upon Getopt::Long error as well --- bin/efa | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bin/efa b/bin/efa index 9ac12ff..40c2ef1 100755 --- a/bin/efa +++ b/bin/efa @@ -15,22 +15,24 @@ my $ignore_info = 'Fahrradmitnahme'; my $efa; my ( @from, @to, @via, $from_type, $to_type, $via_type ); my $opt = { - 'help' => \&show_help, - , + 'help' => sub { show_help(0) }, 'ignore-info' => \$ignore_info, 'from' => \@from, 'to' => \@to, - 'version' => sub { say "efa version $VERSION"; exit 0 }, - 'via' => \@via, + 'version' => sub { say "efa version $VERSION"; exit 0 }, + 'via' => \@via, }; binmode( STDOUT, ':encoding(utf-8)' ); binmode( STDERR, ':encoding(utf-8)' ); sub show_help { + my ($exit_status) = @_; + say 'Usage: efa [options] '; say 'See also: man efa'; - exit 0; + + exit $exit_status; } sub handle_efa_exception { @@ -122,7 +124,7 @@ GetOptions( via=s@{2} walk-speed|w=s }, -) or die("Please see perldoc -F $0\n"); +) or show_help(1); #>>> if ( not( @from and @to ) ) { if ( @ARGV == 4 ) { -- cgit v1.2.3