Switch to side-by-side view

--- a/src/index/recollindex.cpp
+++ b/src/index/recollindex.cpp
@@ -1,5 +1,5 @@
 #ifndef lint
-static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.11 2005-11-05 14:40:50 dockes Exp $ (C) 2004 J.F.Dockes";
+static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.12 2005-11-30 09:46:25 dockes Exp $ (C) 2004 J.F.Dockes";
 #endif
 
 #include <stdio.h>
@@ -24,8 +24,46 @@
     exit(1);
 }
 
+static const char *thisprog;
+static int     op_flags;
+#define OPT_MOINS 0x1
+#define OPT_z     0x2 
+#define OPT_h     0x4 
+
+static const char usage [] =
+"  recollindex [-hz]\n"
+"Options:\n"
+" -h : print this message\n"
+" -z : reset database before starting indexation\n\n"
+;
+
+static void
+Usage(void)
+{
+    FILE *fp = (op_flags & OPT_h) ? stdout : stderr;
+    fprintf(fp, "%s: usage: %s", thisprog, usage);
+    exit((op_flags & OPT_h)==0);
+}
+
+
 int main(int argc, const char **argv)
 {
+    thisprog = argv[0];
+    argc--; argv++;
+
+    while (argc > 0 && **argv == '-') {
+	(*argv)++;
+	if (!(**argv))
+	    Usage();
+	while (**argv)
+	    switch (*(*argv)++) {
+	    case 'z': op_flags |= OPT_z; break;
+	    case 'h': op_flags |= OPT_h; break;
+	    default: Usage(); break;
+	    }
+    }
+    if (op_flags & OPT_h)
+	Usage();
     string reason;
     RclConfig *config = recollinit(cleanup, sigcleanup, reason);
 
@@ -35,7 +73,8 @@
 	fprintf(stderr, "%s\n", str.c_str());
 	exit(1);
     }
+
     indexer = new ConfIndexer(config);
   
-    exit(!indexer->index());
+    exit(!indexer->index((op_flags & OPT_z) != 0));
 }