X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2Fgimmick%2Fmain.cxx;h=516dfd45c312412751fe82ef6a9ce37e95fbc743;hb=19b4ff2b6d359e79a7f723dea0e5cf500e7d619c;hp=d90f0b8bcfa15f955261f571e2bef05c284c78d1;hpb=bae4df8a3e1ea669400c3a6c44ef4aa8d90fa1ed;p=creaImageIO.git diff --git a/appli/gimmick/main.cxx b/appli/gimmick/main.cxx index d90f0b8..516dfd4 100644 --- a/appli/gimmick/main.cxx +++ b/appli/gimmick/main.cxx @@ -1,18 +1,50 @@ #include #include +#include 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; }