support for some argument pass-thru for mig-quick
authorJason Etheridge <jason@esilibrary.com>
Mon, 26 Feb 2018 02:30:32 +0000 (21:30 -0500)
committerJason Etheridge <jason@esilibrary.com>
Mon, 26 Feb 2018 02:30:32 +0000 (21:30 -0500)
mig-bin/mig-quick

index 413724c..ba1d7ac 100755 (executable)
@@ -18,9 +18,16 @@ mig stage
 
 =back
 
+Arguments take the form of --cmd--argument or --cmd--argument=value.
+
+This form is NOT supported: --cmd--argument value
+
+cmd must be substituted with either add, skip-iconv, clean, convert, or stage,
+and determines which mig command to apply the argument toward.
+
 =head1 SYNOPSIS
 
-B<mig-quick> <file1> [<file2> ...]
+B<mig-quick> [arguments...] <file1> [<file2> ...]
 
 =cut
 
@@ -34,15 +41,24 @@ my $mig_bin = "$FindBin::Bin/";
 use lib "$FindBin::Bin/";
 use Mig;
 
-foreach my $file (@ARGV) {
+my @files = grep {!/^--/} @ARGV;
+my %pass_thru = ('add'=>[],'skip-iconv'=>[],'clean'=>[],'convert'=>[],'stage'=>[]);
+foreach my $a (@ARGV) {
+    if ($a =~ /^--([a-z]+)-(.*)$/) {
+        $pass_thru{$1} = [] if ! defined $pass_thru{$1};
+        unshift $pass_thru{$1}, "--$2";
+    }
+}
+
+foreach my $file (@files) {
     foreach my $cmd (('add','skip-iconv','clean','convert','stage')) {
-        print "mig $cmd $file\n";
+        print "mig $cmd $file " . (join ' ', @{ $pass_thru{$cmd} }) . "\n";
         my @MYARGV = (
              'mig'
             ,$cmd
             ,$file
         );
-        print "rc = " . system(@MYARGV) . "\n";
+        system(@MYARGV,@{ $pass_thru{$cmd} });
     }
 }