File indexing completed on 2026-07-26 08:22:13
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "traccc/options/program_options.hpp"
0010
0011 #include "traccc/examples/utils/printable.hpp"
0012
0013
0014 #include <cstdlib>
0015 #include <iostream>
0016
0017 namespace traccc::opts {
0018
0019 program_options::program_options(
0020 std::string_view description,
0021 const std::vector<std::reference_wrapper<interface> >& options, int argc,
0022 char* argv[], std::unique_ptr<const traccc::Logger> ilogger)
0023 : m_desc(std::string{description}) {
0024 TRACCC_LOCAL_LOGGER(std::move(ilogger));
0025
0026
0027 for (const interface& opt : options) {
0028 m_desc.add(opt.options());
0029 }
0030
0031 m_desc.add_options()("help,h", "Print this help message");
0032
0033
0034 boost::program_options::variables_map vm;
0035 boost::program_options::store(
0036 boost::program_options::parse_command_line(argc, argv, m_desc), vm);
0037
0038
0039 if (vm.count("help")) {
0040 std::cout << m_desc << std::endl;
0041 std::exit(0);
0042 }
0043
0044
0045 try {
0046 boost::program_options::notify(vm);
0047 } catch (const std::exception& ex) {
0048 TRACCC_FATAL("Couldn't interpret command line options because of: "
0049 << ex.what() << "; " << m_desc);
0050 std::exit(1);
0051 }
0052
0053
0054 for (interface& opt : options) {
0055 opt.read(vm);
0056 }
0057
0058
0059 TRACCC_INFO("\nRunning " << description);
0060
0061 configuration_list cl;
0062
0063 for (const auto& opt : options) {
0064 cl.add_child(opt.get().as_printable());
0065 }
0066
0067 TRACCC_INFO("\n" << cl.print() << "\n");
0068 }
0069
0070 }