#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;
}