]> Creatis software - creaImageIO.git/blobdiff - appli/gimmick/main.cxx
*** empty log message ***
[creaImageIO.git] / appli / gimmick / main.cxx
index d90f0b8bcfa15f955261f571e2bef05c284c78d1..516dfd45c312412751fe82ef6a9ce37e95fbc743 100644 (file)
@@ -1,18 +1,50 @@
 #include <creaImageIOGimmick.h>
 #include <creaMessageManager.h>
+#include <gimmick_ggo.h>
 
 int main(int argc, char* argv[])
 {
-  bool debug = false;
-  if(argc>1) 
+  gengetopt_args_info args;
+  if (cmdline_parser (argc, argv, &args) != 0) exit(1) ;
+     
+  creaImageIO::Gimmick g;
+  if (args.verbose_given) g.SetMessageLevel(args.verbose_arg);
+    
+  bool something_to_do = 
+    args.dir_given |
+    args.file_given |
+    args.print_given;
+
+  if (!something_to_do)
     {
-      debug = true;
+      std::cout << "Nothing to do !" << std::endl;
+      exit(0);
     }
 
-  creaImageIO::Gimmick g;
-  g.SetDebugMode(debug);
-
-  if (!g.Initialize()) return 1;
-  if (!g.Finalize()) return 1;
+  try
+    {
+      if (!g.Initialize()) return 1;
+      
+      if (args.file_given) 
+       {
+         g.AddFileToLocalDatabase(args.file_arg);
+       }
+      if (args.dir_given) 
+       {
+         g.AddDirToLocalDatabase(args.dir_arg, args.recurse_given);
+       }
+      
+      if (args.print_given) 
+       {
+         g.GetLocalDatabase()->LoadChildren(0,0);
+         g.PrintLocalDatabase();
+       }
+      
+      if (!g.Finalize()) return 1;
+    }
+  catch (crea::Exception e)
+    {
+      e.Print();
+    }
   return 0;
 }