Line data Source code
1 : // DUNE DAQ modification notice:
2 : // This file has been modified from the original ATLAS dbe source for the DUNE DAQ project.
3 : // Fork baseline commit: dbe-02-12-17 (2022-05-12).
4 : // Renamed since fork: yes (from src/SchemaEditor/SchemaMain.cpp to apps/SchemaMain.cpp).
5 :
6 : #include "dbe/SchemaMainWindow.hpp"
7 : #include <QApplication>
8 : #include <boost/program_options.hpp>
9 : #include <iostream>
10 : #include <string>
11 :
12 : namespace bop = boost::program_options;
13 :
14 : int
15 0 : main(int argc, char* argv[])
16 : {
17 0 : std::string oksfn;
18 :
19 0 : bop::options_description options_description("Allowed options", 128);
20 :
21 0 : options_description.add_options()("help,h", "Provide help message")(
22 0 : "file,f", bop::value<std::string>(&oksfn)->default_value(oksfn), "OKS schema file name");
23 :
24 0 : bop::variables_map options_map;
25 :
26 0 : try {
27 0 : bop::parsed_options parsed =
28 0 : bop::command_line_parser(argc, argv).options(options_description).allow_unregistered().run();
29 :
30 : // This is to properly catch any positional argument (not supported)
31 0 : const auto& unknown = bop::collect_unrecognized(parsed.options, bop::include_positional);
32 0 : if (unknown.size() != 0) {
33 0 : std::cerr << "Incorrect command line argument, unrecognized options: ";
34 0 : for (const auto& o : unknown) {
35 0 : std::cerr << o << " ";
36 : }
37 0 : std::cerr << std::endl;
38 :
39 : return EXIT_FAILURE;
40 : }
41 :
42 0 : bop::store(parsed, options_map);
43 0 : bop::notify(options_map);
44 :
45 0 : auto display_help_message = [&options_description]() {
46 0 : std::cout << "TDAQ online database schema editor" << std::endl
47 0 : << std::endl
48 0 : << "Usage: schemaeditor [options]" << std::endl
49 0 : << std::endl
50 0 : << options_description << std::endl;
51 0 : };
52 :
53 0 : if (options_map.count("help")) {
54 0 : display_help_message();
55 : return EXIT_SUCCESS;
56 : }
57 0 : } catch (std::exception const& e) {
58 0 : std::cerr << "Incorrect command line argument: " << e.what() << std::endl;
59 0 : return EXIT_FAILURE;
60 0 : }
61 :
62 0 : QApplication a(argc, argv);
63 :
64 0 : dbse::SchemaMainWindow w(QString::fromStdString(oksfn));
65 :
66 0 : w.show();
67 :
68 0 : return a.exec();
69 0 : }
|