10#include <framework/core/FileCatalog.h>
11#include <framework/dataobjects/FileMetaData.h>
12#include <framework/io/RootFileInfo.h>
13#include <framework/logging/Logger.h>
24#include <boost/program_options.hpp>
27namespace prog = boost::program_options;
29int main(
int argc,
char* argv[])
34 if (std::signal(SIGPIPE, SIG_DFL) == SIG_ERR)
35 B2FATAL(
"Cannot remove SIGPIPE signal handler");
38 prog::options_description options(
"Options");
40 (
"help,h",
"print all available options")
41 (
"file,f", prog::value<std::string>(),
"local file name")
42 (
"lfn,l", prog::value<std::string>(),
"logical file name")
43 (
"all,a",
"print all information")
44 (
"json",
"print machine-readable information in JSON format. Implies --all and --steering.")
45 (
"steering,s",
"print steering file contents")
48 prog::positional_options_description posOptDesc;
49 posOptDesc.add(
"file", -1);
51 prog::variables_map varMap;
53 prog::store(prog::command_line_parser(argc, argv).
54 options(options).positional(posOptDesc).run(), varMap);
56 }
catch (std::exception& e) {
57 std::cout <<
"Problem parsing command line: " << e.what() << std::endl;
58 std::cout <<
"Usage: " << argv[0] <<
" [OPTIONS] [FILE]\n";
59 std::cout << options << std::endl;
64 if (varMap.count(
"help") or argc == 1) {
65 std::cout <<
"Usage: " << argv[0] <<
" [OPTIONS] [FILE]\n";
66 std::cout << options << std::endl;
73 if (varMap.count(
"file")) {
74 gErrorIgnoreLevel = kError;
75 std::string fileName = varMap[
"file"].as<std::string>();
78 metaData = fileInfo.getFileMetaData();
79 }
catch (
const std::invalid_argument&) {
80 B2FATAL(
"The input file can not be opened"
81 <<
LogVar(
"File name", fileName));
82 }
catch (
const std::runtime_error& e) {
83 B2FATAL(
"Something went wrong with the input file"
84 <<
LogVar(
"File name", fileName)
85 <<
LogVar(
"Issue", e.what()));
87 }
else if (varMap.count(
"lfn")) {
88 std::string lfn = varMap[
"lfn"].as<std::string>();
90 B2FATAL(
"No FileMetaData found in FileCatalog"
91 <<
LogVar(
"LFN", varMap[
"lfn"].as<int>()));
93 B2FATAL(
"Please specify either a file name or a LFN.");
95 const char* option =
"";
96 if (varMap.count(
"json"))
98 else if (varMap.count(
"all"))
100 metaData.Print(option);
101 if (std::string(option) !=
"json" and varMap.count(
"steering"))
102 metaData.Print(
"steering");
static FileCatalog & Instance()
Static method to get a reference to the FileCatalog instance.
virtual bool getMetaData(std::string &fileName, FileMetaData &metaData)
Get the metadata of a file with given (logical) file name.
Helper class to factorize some necessary tasks when working with Belle2 output files.
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.