CbmRoot
Loading...
Searching...
No Matches
qareport/ApplicationParameter.cxx
Go to the documentation of this file.
1/* Copyright (C) 2025 GSI/VECC, Darmstadt/Kolkata
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Souvik Chattopadhyay[committer] */
4
5
7
8#include <boost/program_options.hpp>
9
10#include <iostream>
11#include <stdexcept>
12
13namespace po = boost::program_options;
14
15// -----------------------------------------------------------------------------
16ApplicationParameter::ApplicationParameter(int argc, char* argv[]) { ParseCommandLine(argc, argv); }
17
18// -----------------------------------------------------------------------------
19void ApplicationParameter::ParseCommandLine(int argc, char* argv[])
20{
21 try {
22 // 1) Define the recognised options
23 po::options_description desc("Allowed options");
24 desc.add_options()("inputfile,i", po::value<std::string>(&this->qaFile)->required()->value_name("<qaFile.root>"),
25 "Input QA ROOT file")(
26 "setup,s", po::value<std::string>(&this->setup)->required()->value_name("<setupTag>"), "Setup tag (e.g. s100c)")(
27 "out-dir,o", po::value<std::string>(&this->outDir)->default_value("./report"),
28 "Output directory")("engine,e", po::value<std::string>(&this->engine)->default_value("latex"),
29 "Report engine: html | latex | beamer")(
30 "fig-ext,f", po::value<std::string>(&this->figExt)->default_value("png"),
31 "Figure file extension")("ignoresame,r", po::bool_switch(&this->ignoreSame)->default_value(false),
32 "Ignore same results")("help,h", "Show help message (ignored no printing here)");
33
34 // 2) Parse the command line
35 po::variables_map vars;
36 po::store(po::parse_command_line(argc, argv, desc), vars);
37
38 // 3) Check for help request
39 if (vars.count("help")) {
40 std::cout << desc << std::endl;
41 exit(EXIT_SUCCESS);
42 }
43
44 // 4) Enforce required and defaulted values
45 po::notify(vars);
46
47 // 5) Check for required options manually (already enforced by notify)
48 if (this->qaFile.empty() || this->setup.empty()) {
49 throw std::runtime_error("Missing required options: --qa-file and --setup are mandatory.");
50 }
51 }
52 catch (const po::error& e) {
53 std::cerr << "Error: " << e.what() << std::endl;
54 std::cerr << "Use -h or --help for usage information." << std::endl;
55 exit(EXIT_FAILURE);
56 }
57}
std::string figExt
png | svg | pdf
std::string engine
html | latex | beamer
bool ignoreSame
ignore "same" results in comparison tables
void ParseCommandLine(int argc, char *argv[])
Parses command-line arguments.
ApplicationParameter(int argc, char *argv[])
Constructor: Parses command-line arguments.
std::string outDir
where figures & script will go
std::string qaFile
input ROOT file