CbmRoot
Loading...
Searching...
No Matches
qa/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], Sergei Zharko */
4
6
7#include <boost/program_options.hpp>
8
9#include <iostream>
10
11namespace po = boost::program_options;
12
14ApplicationParameter::ApplicationParameter(int argc, char* argv[]) { ParseCommandLine(argc, argv); }
15
17void ApplicationParameter::ParseCommandLine(int argc, char* argv[])
18{
19 try {
20 std::string sCompare{}; // Temporary buffer for string parsing
21
22 // Define command-line options
23 po::options_description desc("Allowed options");
24 desc.add_options()("help,h", "Display help message")(
25 "compare,t", po::value<std::string>(&sCompare)->required()->value_name("commit"),
26 "Specify comparison type (only 'commit' or 'weeklyTest' are allowed)")(
27 "names,n", po::value<std::vector<std::string>>(&fNames)->multitoken()->value_name("<hash1 hash2 ...>"),
28 "List of commit hash or week numbers(yyyy_ww). It will act as Version in the config file")(
29 "output,o", po::value<std::string>(&fOutput)->default_value("./output_compare_qa.root"),
30 "Specify output file name")(
31 "config,c", po::value<std::string>(&fConfig)->default_value("macro/qa/configs/objects_weekly.yaml"),
32 "Specify config file")("builddir,b", po::value<std::string>(&fBuilddir)->default_value(""),
33 "Specify cbmroot build directory")(
34 "option,p", po::value<std::string>(&fOption)->default_value("ESR"),
35 "Specify the option for comparison (e.g., E for exact)");
36
37 // Parse command-line arguments
38 po::variables_map vars;
39 po::store(po::parse_command_line(argc, argv, desc), vars);
40
41 // Handle help request
42 if (vars.count("help")) {
43 std::cout << desc << std::endl;
44 exit(EXIT_SUCCESS);
45 }
46
47 // Apply required options
48 po::notify(vars);
49
50 // Convert string to enum
51 if (sCompare == "commit") {
53 }
54 else if (sCompare == "weeklyTest") {
56 }
57 else {
58 throw po::validation_error(po::validation_error::invalid_option_value, "compare", sCompare);
59 }
60 }
61 catch (const po::error& e) {
62 std::cerr << "Error: " << e.what() << std::endl;
63 exit(EXIT_FAILURE);
64 }
65}
std::string fConfig
A path to the YAML configuration file.
std::string fOption
An option to select the comparision methods and canvas handling using core::Process()
void ParseCommandLine(int argc, char *argv[])
Parses command-line arguments.
std::string fOutput
A path to the output root file.
ApplicationParameter(int argc, char *argv[])
Constructor: Parses command-line arguments.
std::vector< std::string > fNames
List of commit hashes or week numbers (yyyy_ww)
std::string fBuilddir
A path to CBMROOT build directory.
ETestType fCompare
selected comparision type
@ Commit
Commit-based comparision mode.
@ Weekly
Weekly test comparision mode.