#! /usr/bin/env perl
# $Id$
+# $URL$
=head1 NAME
=head1 SYNOPSIS
-B<fa-flacd> [B<-jv>]
+B<fa-flacd> [B<-j> I<jobs>] [B<-v>]
=cut
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;
'cue', '--no-padding', '--best',
map({ ('-T', $_) } @tags),
'wav');
- if (WIFEXITED($status) and ($status = WEXITSTATUS($status)) != 0) {
- die("flac: $status");
+ if (WIFEXITED($status)) {
+ if (($status = WEXITSTATUS($status)) != 0) {
+ die("flac exited with status $status");
+ }
} elsif (WIFSIGNALED($status)) {
die("flac killed with signal ", WTERMSIG($status));
} elsif (WIFSTOPPED($status)) {
die("flac stopped with signal ", WSTOPSIG($status));
+ } else {
+ die("Major horkage on system(flac): \$? = $? \$! = $!");
}
verbose("Cleaning up $dir\n");
verbose("$pid finished (");
if (WIFEXITED($status)) {
- verbose('exited ', WEXITSTATUS($status));
+ verbose('exited with status ', WEXITSTATUS($status));
} elsif (WIFSIGNALED($status)) {
- verbose('signalled ', WTERMSIG($status));
+ verbose('killed with signal ', WTERMSIG($status));
} elsif (WIFSTOPPED($status)) {
- verbose('stopped ', WSTOPSIG($status));
+ verbose('stopped with signal ', WSTOPSIG($status));
}
verbose(")\n");
}
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
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>.