Small correction in help string.
[gedcom-parse.git] / t / src / gomtest.c
index ad165fb1ac5d56decb329209984c26c3fbda89c7..07cc066e1a9fc448a95229fbfcc8fe64400efb01 100644 (file)
@@ -24,6 +24,7 @@
 #include "gom.h"
 #include "output.h"
 #include "dump_gom.h"
+#include "portability.h"
 #include <stdio.h>
 #include <locale.h>
 #include "gedcom.h"
@@ -41,6 +42,7 @@ void show_help ()
   printf("  -dg   Debug setting: only libgedcom debug messages\n");
   printf("  -da   Debug setting: libgedcom + yacc debug messages\n");
   printf("  -q    No output to standard output\n");
+  printf("  -o <outfile>  File to generate output to (def. testgedcom.out)\n");
 }
 
 void gedcom_message_handler(Gedcom_msg_type type, char *msg)
@@ -54,6 +56,7 @@ int main(int argc, char* argv[])
   int compat_enabled = 1;
   int debug_level = 0;
   int result      = 0;
+  char* outfilename = NULL;
   char* file_name = NULL;
 
   if (argc > 1) {
@@ -78,6 +81,17 @@ int main(int argc, char* argv[])
       else if (!strncmp(argv[i], "-q", 3)) {
        output_set_quiet(1);
       }
+      else if (!strncmp(argv[i], "-o", 3)) {
+       i++;
+       if (i < argc) {
+         outfilename = argv[i];
+       }
+       else {
+         printf ("Missing output file name\n");
+         show_help();
+         exit(1);
+       }
+      }
       else if (strncmp(argv[i], "-", 1)) {
        file_name = argv[i];
        break;
@@ -103,8 +117,8 @@ int main(int argc, char* argv[])
   gedcom_set_error_handling(mech);
   gedcom_set_message_handler(gedcom_message_handler);
 
-  output_open();
-  output(0, "\n=== Parsing file %s\n", file_name);
+  output_open(outfilename);
+  output(0, "\n=== Parsing file %s\n", simple_base_name(file_name));
   result = gom_parse_file(file_name);
   if (result == 0) {
     output(1, "Parse succeeded\n");