summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-07-20 13:46:14 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-07-20 13:46:14 +0200
commit253e74d49ac3ec7f064aa0fc18eafc3b09cde9a4 (patch)
tree9dbf790118de840ab449c4c7015201bd2cebdc99
parenta22ee15c603e3fb7066fdd2eca8adf192719ca97 (diff)
Use Getopt::Long
-rw-r--r--Build.PL1
-rwxr-xr-xbin/raps210
2 files changed, 8 insertions, 3 deletions
diff --git a/Build.PL b/Build.PL
index cfaf26f..cc82474 100644
--- a/Build.PL
+++ b/Build.PL
@@ -22,6 +22,7 @@ my $build = Module::Build->new(
'File::BaseDir' => 0,
'File::Path' => 2.06_05,
'File::Slurp' => 0,
+ 'Getopt::Long' => 0,
'POSIX' => 0,
'Term::ReadLine' => 0,
},
diff --git a/bin/raps2 b/bin/raps2
index 45c6149..e3c78b0 100755
--- a/bin/raps2
+++ b/bin/raps2
@@ -9,12 +9,19 @@ use 5.010;
use App::Raps2;
use File::BaseDir qw(data_files data_home);
use File::Slurp qw(read_dir);
+use Getopt::Long qw(:config no_ignore_case);
my $raps2 = App::Raps2->new();
my ( $action, @args ) = @ARGV;
our $VERSION = '0.50';
+GetOptions(
+ 'h|help' => sub { cmd_help(0) },
+ 'V|version' => sub { say "raps2 version ${VERSION}"; exit 0 },
+
+) or cmd_help(1);
+
sub file_must_exist {
my ( $file, $name ) = @_;
@@ -225,9 +232,6 @@ given ($action) {
when ('info') { cmd_info(@args) }
when ('list') { cmd_list(@args) }
- when ( [qw[version -v --version]] ) { say "raps2 version ${VERSION}" }
- when ( [qw[help -h --help ]] ) { cmd_help(0) }
-
default { cmd_help(1) }
}