22bool initOptionsAndParse(bpo::options_description& options,
int argc,
char* argv[], bpo::variables_map& vm)
24 options.add_options()(
25 "host", bpo::value<std::string>()->default_value(
"alice-ccdb.cern.ch"),
"CCDB server")(
26 "path,p", bpo::value<std::vector<std::string>>()->multitoken(),
"CCDB path (identifies the object) [or space separated list of paths for batch processing]")(
27 "dest,d", bpo::value<std::string>()->default_value(
"./"),
"destination path")(
28 "no-preserve-path",
"Do not preserve path structure. If not set, the full path structure -- reflecting the '--path' argument will be put.")(
29 "outfile,o", bpo::value<std::string>()->default_value(
"snapshot.root"),
"Name of output file. If set to \"\", the name will be determined from the uploaded content. (Will be the same in case of batch downloading multiple paths.)")(
30 "timestamp,t", bpo::value<long>()->default_value(-1),
"timestamp in ms - default -1 = now")(
31 "created-not-before", bpo::value<long>()->default_value(0),
"CCDB created-not-before time (Time Machine)")(
32 "created-not-after", bpo::value<long>()->default_value(3385078236000),
"CCDB created-not-after time (Time Machine)")(
33 "help,h",
"Produce help message.");
36 bpo::store(parse_command_line(argc, argv, options), vm);
39 if (vm.count(
"help")) {
40 std::cout << options << std::endl;
45 }
catch (
const bpo::error& e) {
46 std::cerr << e.what() <<
"\n\n";
47 std::cerr <<
"Error parsing command line arguments; Available options:\n";
49 std::cerr << options << std::endl;
56int main(
int argc,
char* argv[])
58 bpo::options_description options(
"Allowed options");
59 bpo::variables_map vm;
65 auto host = vm[
"host"].as<std::string>();
68 std::map<std::string, std::string>
filter;
69 long timestamp = vm[
"timestamp"].as<
long>();
70 if (timestamp == -1) {
73 auto paths = vm[
"path"].as<std::vector<std::string>>();
74 auto dest = vm[
"dest"].as<std::string>();
75 if (
paths.size() == 0) {
76 std::cerr <<
"No path given";
80 std::cout <<
"Querying host " << host <<
" for path(s) " <<
paths[0] <<
" ... and timestamp " << timestamp <<
"\n";
81 bool no_preserve_path = vm.count(
"no-preserve-path") == 0;
82 auto filename = vm[
"outfile"].as<std::string>();
83 auto notBefore = vm[
"created-not-before"].as<
long>();
84 auto notAfter = vm[
"created-not-after"].as<
long>();
87 for (
auto& p :
paths) {
91 return success ? 0 : 1;
bool retrieveBlob(std::string const &path, std::string const &targetdir, std::map< std::string, std::string > const &metadata, long timestamp, bool preservePathStructure=true, std::string const &localFileName="snapshot.root", std::string const &createdNotAfter="", std::string const &createdNotBefore="") const