42 std::string handler(
"Local database");
45 po::options_description
generic(
"GENERIC");
47 (
"help,h",
"Print help and exit")
48 (
"version,V",
"Print version and exit");
51 po::options_description command(
"COMMANDS");
53 (
"print,p",
"Prints the local database tree (default=off)")
54 (
"files,f",po::value< vector<string> >(),
"Adds the file(s) to the local database")
55 (
"dir,d",po::value< vector<string> >(),
"Adds the directory to the local database")
56 (
"sync,s",po::value< vector<string> >(),
"Synchronizes the local database with the files")
57 (
"copy,c",po::value< vector<string> >(),
"Copies the files into a local directory");
60 po::options_description option(
"OPTIONS");
62 (
"verbose,v",po::value<int>(&verb),
"Verbosity level (default=`1')")
63 (
"debug,D",po::value<int>(&deb),
"Debug messages level (default=`0')")
64 (
"recurse,r",
"Recurse into sub-directories (default=off)")
65 (
"repair,R",
"Repair the database (on synchronization) (default=off)")
66 (
"check,C",
"Check for attribute differences (on synchronization) (default=off)")
67 (
"handler,H",po::value<string>(&handler),
"Handler name (default=`Local database')");
70 po::options_description cmdline_options;
71 cmdline_options.add(
generic).add(command).add(option);
75 po::store(po::parse_command_line(ac, av, cmdline_options), vm);
81 if (vm.count(
"help")) {
82 cout <<
"Usage: gimmick COMMAND [OPTIONS]:\n";
83 cout << cmdline_options <<
"\n";
85 if (vm.count(
"version")) {
86 cout <<
"gimmick 0.1.0\n";
90 if (vm.count(
"verbose")) {
92 cout <<
"Verbose level is now "<<verb<<
"\n";
94 if (vm.count(
"debug")) {
96 cout <<
"Debug level is now "<<deb<<
"\n";
100 if ( vm.count(
"print")
111 if (vm.count(
"print")) {
115 if (vm.count(
"file")) {
116 std::vector<std::string> files=vm[
"file"].as< vector<string> >();
119 if (vm.count(
"dir")) {
120 std::vector<std::string> dirs=vm[
"dir"].as< vector<string> >();
122 std::stringstream out;
123 out<<vm.count(
"recurse");
124 if(out.str().compare(
"1")==0){recu=
true;}
125 g.
AddDir(handler,dirs.front(), recu);
127 if (vm.count(
"sync")) {
130 std::vector<std::string> name=vm[
"sync"].as< vector<string> >();
131 std::stringstream out;
132 out<<vm.count(
"repair");
133 if(out.str().compare(
"1")==0){rep=
true;}
134 std::stringstream out2;
135 out2<<vm.count(
"check");
136 if(out2.str().compare(
"1")==0){chk=
true;}
139 if (vm.count(
"copy")) {
140 std::vector<std::string> name=vm[
"copy"].as< vector<string> >();
145 catch (crea::Exception e)