]> diplodocus.org Git - flac-archive/commitdiff
Use Getopt::Long and Pod::Usage instead of Getopt::Std. As a side
authorepg <>
Wed, 27 Oct 2004 05:05:16 +0000 (05:05 +0000)
committerepg <>
Wed, 27 Oct 2004 05:05:16 +0000 (05:05 +0000)
effect, support long options.  Add OPTIONS documentation section.

fa-flacd

index 2cc1210..6bae1f0 100755 (executable)
--- a/fa-flacd
+++ b/fa-flacd
@@ -8,7 +8,7 @@ B<fa-flacd> - archive CDs to single FLAC files
 
 =head1 SYNOPSIS
 
-B<fa-flacd> [B<-jv>]
+B<fa-flacd> [B<-j> I<jobs>] [B<-v>]
 
 =cut
 
@@ -16,10 +16,9 @@ use strict;
 use warnings;
 
 use File::Basename;
-use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1;
+use Getopt::Long qw(:config gnu_getopt no_ignore_case);
 use POSIX ':sys_wait_h';
-
-our $VERSION = 1;
+use Pod::Usage;
 
 my $verbose;
 my @jobs;
@@ -189,18 +188,18 @@ sub flacloop {
 }
 
 MAIN: {
-    my %opts;
-
-    $opts{'j'} = 4;
-    $opts{'v'} = 0;
-    if (not getopts('j:v', \%opts)) {
-        print(STDERR "usage: flacd [-jN -v]\n");
-        exit(2);
-    }
-
-    $verbose = $opts{'v'};
-
-    flacloop($opts{'j'});
+    my $jobs;
+    my $help;
+
+    $jobs = 4;
+    GetOptions(
+               'jobs|j=i' => \$jobs,
+               'verbose|v' => \$verbose,
+               'help|h|?' => \$help,
+              ) or pod2usage();
+    $help and pod2usage(-exitstatus=>0, -verbose=>1);
+
+    flacloop($jobs);
 }
 
 \f
@@ -237,6 +236,20 @@ the "log" file.  Finally, B<fa-flacd> moves the "cue" and "log" files
 to the artist directory (named by album) and removes the temporary
 directory.
 
+=head1 OPTIONS
+
+=over 4
+
+=item B<-j> [B<--jobs>] I<jobs>
+
+Run up to I<jobs> jobs instead of the default 4.
+
+=item B<-v> [B<--verbose>]
+
+Print diagnostic information.
+
+=back
+
 =head1 AUTHORS
 
 Written by Eric Gillespie <epg@pretzelnet.org>.