cleaned up version of arguments
[migration-tools.git] / mig
diff --git a/mig b/mig
index ea6cfd1..05d0196 100755 (executable)
--- a/mig
+++ b/mig
@@ -63,6 +63,10 @@ Using B<mig> should go something like this:
 
 =item mig write_prod patrons.tsv # creates a .sql file for pushing the staging data into production
 
+=item mig reporter --analyst "Foo Fooer" --report_title "Foo Load Analysis" #creates an asciidoc report
+
+=item mig gsheet --pull foo_tab_name OR --push foo_pg_table_name 
+
 =back
 
 =head1 COMMANDS
@@ -226,6 +230,43 @@ or for all mapped files if no file is specified.
 Generates <parent table>_prod.sql for the specified linked and mapped file, or
 all such files if no file is specified.
 
+=item B<sql> [arguments...]
+
+A wrapper around the psql command.  At some point the plan is to shove mig-tracked variables into psql sessions.
+
+=item B<reporter> --analyst "Analyst Name" --report_title "Report Title"
+
+Generates an asciidoc file in the git working directory that can be converted to 
+any appropriate format.  The analyst and report parameters are required.
+
+Optional parameters are : 
+
+--added_page_title and --added_page_file 
+
+If one is used both must be.  The added page file can be plain text or asciidoc.  This
+adds an extra arbitrary page of notes to the report.  Mig assumes the page file is in the mig git directory.
+
+--tags
+
+This will define a set of tags to use, if not set it will default to Circs, 
+Holds, Actors, Bibs, Assets & Money. 
+
+--debug
+
+Gives more information about what is happening.
+
+--reports_xml 
+
+Allows you to override the default evergreen_staged_report.xml in the mig-xml folder.
+
+=item B<gsheet> --pull or --push spreadsheet_tab
+
+This uses the gsheet_tracked_table and gsheet_tracked column tables to map a Google Docs Spreadsheet tabs
+with Postgres tables in the mig schema.  The spreadsheet is assumed to share the name as the mig schema. 
+Tab names must be unique.  Each spreadsheet column needs a header that matches the column name in the matching 
+table.  An oauth session key is also needed for your Google account and mig gsheet will look for it in the 
+.mig directory.
+
 =back
 
 =cut
@@ -258,70 +299,9 @@ switch($ARGV[0]) {
             pod2usage(-verbose => 2);
         }
     }
-    case "env" {
-        standard_invocation(@ARGV);
-    }
-    case "init" {
-        Mig::die_if_no_env_migschema();
-        standard_invocation(@ARGV);
-    }
-    case "status" {
-        Mig::die_if_no_env_migschema();
-        standard_invocation(@ARGV);
-    }
-    case "add" {
-        Mig::die_if_no_env_migschema();
-        standard_invocation(@ARGV);
-    }
-    case "remove" {
-        Mig::die_if_no_env_migschema();
-        standard_invocation(@ARGV);
-    }
-    case "iconv" {
-        Mig::die_if_no_env_migschema();
-        standard_invocation(@ARGV);
-    }
-    case "skip-iconv" {
-        Mig::die_if_no_env_migschema();
-        standard_invocation(@ARGV);
-    }
-    case "clean" {
-        Mig::die_if_no_env_migschema();
-        standard_invocation(@ARGV);
-    }
-    case "skip-clean" {
-        Mig::die_if_no_env_migschema();
-        standard_invocation(@ARGV);
-    }
-    case "link" {
-        Mig::die_if_no_env_migschema();
-        standard_invocation(@ARGV);
-    }
-    case "unlink" {
-        Mig::die_if_no_env_migschema();
-        standard_invocation(@ARGV);
-    }
-    case "convert" {
-        Mig::die_if_no_env_migschema();
-        standard_invocation(@ARGV);
-    }
-    case "stage" {
-        Mig::die_if_no_env_migschema();
-        standard_invocation(@ARGV);
-    }
-    case "mapper" {
-        Mig::die_if_no_env_migschema();
-        standard_invocation(@ARGV);
-    }
-    case "quicksheet" {
-        Mig::die_if_no_env_migschema();
-        standard_invocation(@ARGV);
-    }
     case "map" {
-        Mig::die_if_no_env_migschema();
     }
     case "load" {
-        Mig::die_if_no_env_migschema();
     }
     case "wdir" {
         print "$MIGWORKDIR\n";
@@ -333,13 +313,20 @@ switch($ARGV[0]) {
         print "$MIGGITDIR\n";
     }
     else {
-        pod2usage(1);
+        standard_invocation(@ARGV);
     }
 }
 
 sub standard_invocation {
     my $cmd = shift;
-    system( $mig_bin . "mig-$cmd", @_ );
+
+    Mig::die_if_no_env_migschema();
+    if (-e $mig_bin . "mig-$cmd") {
+        system( $mig_bin . "mig-$cmd", @_ );
+    } else {
+        system( "mig-$cmd", @_ ) == 0 or die pod2usage(1);
+    }
+
 }