seed kmig-quick with emig-quick
[migration-tools.git] / kmig.d / bin / mig-quick
1 #!/usr/bin/perl -w
2 ###############################################################################
3 =pod
4
5 =head1 NAME
6
7 mig-quick 
8
9 A wrapper for running the following mig commands on the specified files:
10
11 =over 15
12
13 mig add
14 mig skip-iconv
15 mig clean
16 mig convert
17 mig stage
18
19 =back
20
21 Arguments take the form of --cmd--argument or --cmd--argument=value.
22
23 This form is NOT supported: --cmd--argument value
24
25 cmd must be substituted with either add, skip-iconv, clean, convert, or stage,
26 and determines which mig command to apply the argument toward.
27
28 =head1 SYNOPSIS
29
30 B<mig-quick> [arguments...] <file1> [<file2> ...]
31
32 =cut
33
34 ###############################################################################
35
36 use strict;
37 use Pod::Usage;
38 use Cwd 'abs_path';
39 use FindBin;
40 my $mig_bin = "$FindBin::Bin/";
41 use lib "$FindBin::Bin/";
42 use EMig;
43
44 my @files = grep {!/^--/} @ARGV;
45 my %pass_thru = ('add'=>[],'skip-iconv'=>[],'clean'=>[],'convert'=>[],'stage'=>[]);
46 foreach my $a (@ARGV) {
47     if ($a =~ /^--([a-z]+)-(.*)$/) {
48         $pass_thru{$1} = [] if ! defined $pass_thru{$1};
49         unshift @{ $pass_thru{$1} }, "--$2";
50     }
51 }
52
53 foreach my $file (@files) {
54     foreach my $cmd (('add','skip-iconv','clean','convert','stage')) {
55         print "mig $cmd $file " . (join ' ', @{ $pass_thru{$cmd} }) . "\n";
56         my @MYARGV = (
57              'mig'
58             ,$cmd
59             ,$file
60         );
61         system(@MYARGV,@{ $pass_thru{$cmd} });
62     }
63 }
64
65 exit 0;
66