From: epg <> Date: Wed, 27 Oct 2004 05:05:16 +0000 (+0000) Subject: Use Getopt::Long and Pod::Usage instead of Getopt::Std. As a side X-Git-Url: https://diplodocus.org/git/flac-archive/commitdiff_plain/8495cd48907a1b86af91c54d1df5388e270c1680?ds=sidebyside Use Getopt::Long and Pod::Usage instead of Getopt::Std. As a side effect, support long options. Add OPTIONS documentation section. --- diff --git a/fa-flacd b/fa-flacd index 2cc1210..6bae1f0 100755 --- a/fa-flacd +++ b/fa-flacd @@ -8,7 +8,7 @@ B - archive CDs to single FLAC files =head1 SYNOPSIS -B [B<-jv>] +B [B<-j> I] [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); } @@ -237,6 +236,20 @@ the "log" file. Finally, B 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 + +Run up to I jobs instead of the default 4. + +=item B<-v> [B<--verbose>] + +Print diagnostic information. + +=back + =head1 AUTHORS Written by Eric Gillespie .