X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2Fgimmick%2Fmain.cxx;h=bee8ff1c269aa6b2137bbd82c9d695eaa1854764;hb=ab4f051eca01a4340f78587f97e89eeb46a8d8a7;hp=274efe70ee6f7d48cbf1fd82c677fa545513c0f1;hpb=388889590eb9b32ded2d830fc7c8d2ab4ca44e83;p=creaImageIO.git diff --git a/appli/gimmick/main.cxx b/appli/gimmick/main.cxx index 274efe7..bee8ff1 100644 --- a/appli/gimmick/main.cxx +++ b/appli/gimmick/main.cxx @@ -1,5 +1,5 @@ #include - + using namespace boost; namespace po = boost::program_options; @@ -10,85 +10,93 @@ using namespace std; int main(int ac, char* av[]) { - - creaImageIO::Gimmick g; - int verb,deb; - std::string handler("Local database"); - - //Describes first group of options - po::options_description generic("GENERIC"); - generic.add_options() + + creaImageIO::Gimmick g; + int verb,deb; + std::string handler("Local database"); + + //Describes first group of options + po::options_description generic("GENERIC"); + generic.add_options() ("help,h", "Print help and exit") - ("version,V", "Print version and exit"); - - //Describes second group of options - po::options_description command("COMMANDS"); - command.add_options() + ("version,V", "Print version and exit"); + + //Describes second group of options + po::options_description command("COMMANDS"); + command.add_options() ("print,p","Prints the local database tree (default=off)") ("file,f",po::value< vector >(),"Adds the file to the local database") - ("dir,d",po::value< vector >(),"Adds the directory to the local database") - ("recurse,r","Recurse into sub-directories (default=off)"); - - //Describes third group of options - po::options_description option("OPTIONS"); - option.add_options() + ("dir,d",po::value< vector >(),"Adds the directory to the local database") + ("sync,s","Synchronizes the local database with the files") + ("recurse,r","Recurse into sub-directories (default=off)"); + + //Describes third group of options + po::options_description option("OPTIONS"); + option.add_options() ("verbose,v",po::value(&verb),"Verbosity level (default=`1')") - ("debug,D",po::value(&deb),"Debug messages level (default=`0')"); - - - //Adds the groups into a big one - po::options_description cmdline_options; - cmdline_options.add(generic).add(command).add(option); - - //Adds the corresponding variables - po::variables_map vm; - po::store(po::parse_command_line(ac, av, cmdline_options), vm); - po::notify(vm); + ("debug,D",po::value(&deb),"Debug messages level (default=`0')"); + + + //Adds the groups into a big one + po::options_description cmdline_options; + cmdline_options.add(generic).add(command).add(option); + + //Adds the corresponding variables + po::variables_map vm; + po::store(po::parse_command_line(ac, av, cmdline_options), vm); + po::notify(vm); + + //Does something on each option + //GENERIC + if (vm.count("help")) { + cout << "Usage: gimmick COMMAND [OPTIONS]:\n"; + cout << cmdline_options << "\n"; + } + if (vm.count("version")) { + cout << "gimmick 0.1.0\n"; + } + + //OPTIONS + if (vm.count("verbose")) { + g.SetMessageLevel(verb); + cout << "Verbose level is now "<LoadChildren(0,0); - g.Print(handler); + g.GetTreeHandler(handler)->LoadChildren(0,0); + g.Print(handler); } if (vm.count("file")) { - std::vector files=vm["file"].as< vector >(); - cout << "Include paths are: " << vm["file"].as< vector >().front() << "\n"; - g.AddFiles(handler,files); + std::vector files=vm["file"].as< vector >(); + g.AddFiles(handler,files); } if (vm.count("dir")) { - std::vector dirs=vm["dir"].as< vector >(); + std::vector dirs=vm["dir"].as< vector >(); g.AddDir(handler,dirs.front(), vm.count("recurse")); } - g.Finalize(); - } - catch (crea::Exception e) - { - e.Print(); - } - + if (vm.count("sync")) { + g.Synchronize(true,g.GetTreeHandler(handler)); + } + g.Finalize(); + } + catch (crea::Exception e) + { + e.Print(); + } + return 0; }