Add slack reporting support

Change-Id: I96fc4ff538416cd391d93023027398e7156d08d1
diff --git a/bin/corpuslist_to_index b/bin/corpuslist_to_index
index b96e969..9f7edbd 100644
--- a/bin/corpuslist_to_index
+++ b/bin/corpuslist_to_index
@@ -16,6 +16,9 @@
 
 my @cmds = ('untar', 'count_json', 'to_index');
 
+my $who = ''; # Worker 05 (10.0.10.57):
+my $comment = '';
+
 GetOptions(
   'batch|b=i'  => \(my $package_size = 15),
   'base-dir|bd=s' => \(my $base_dir = Cwd::cwd()), # '/opt/korap/index-2020-03-30'),
@@ -23,6 +26,7 @@
   'tar-dir|td=s' => \(my $tar_dir = '/export/netapp/korap/krill-json/dereko-2021-1/'),
   'index-dir|id=s' => \(my $index_dir = '/export/netapp/korap/korap-head-02/index-2020-03-30/index'),
   'index-conf|ic=s' => \(my $index_conf = 'kustvakt.conf'),
+  'slack=s' => \(my $slack = ''),
   'cmd|c=s' => \@cmds,
   'help|h' => sub {
     pod2usage(
@@ -127,11 +131,26 @@
   my $from = $lines->[0];
   my $to = $lines->[-1];
 
-  say 'java -jar Krill-Indexer.jar \\';
+  if ($slack) {
+    print '( ( ';
+  };
+  print 'java -jar Krill-Indexer.jar \\' . "\n";
   say '  -c ' . $index_conf . ' \\';
   say '  -i ' . $json_dir . ' \\';
   say '  -o ' . $index_dir . ' \\';
-  say '  &> ' . catfile($base_dir, 'index.' . $from . '-' . $to . '.log') . ' & ' . "\n";
+  print '  &> ' . catfile($base_dir, 'index.' . $from . '-' . $to . '.log');
+
+  if ($slack) {
+    say ' ; \\';
+    print 'slack.js -c ' . $slack . ' ';
+    print '"Done: ' . $who . "indexation $from-$to";
+    if ($comment) {
+      print '(' . $comment . ')';
+    };
+    print '"  ) & )'."\n\n";
+  } else {
+    print ' & ' . "\n\n";
+  };
 
   # Cleanup json directory
   say 'rm -r ' . $json_dir;
@@ -188,6 +207,10 @@
 
 =back
 
+=item B<--slack>
+
+Give a slack channel for reporting.
+
 =back
 
 =cut