DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
SchemaMain.cpp File Reference
#include "dbe/SchemaMainWindow.hpp"
#include <QApplication>
#include <boost/program_options.hpp>
#include <iostream>
#include <string>
Include dependency graph for SchemaMain.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 9 of file SchemaMain.cpp.

9 {
10 std::string oksfn;
11
12 bop::options_description options_description("Allowed options", 128);
13
14 options_description.add_options()("help,h", "Provide help message")
15 ("file,f", bop::value<std::string>(&oksfn)->default_value(oksfn), "OKS schema file name");
16
17 bop::variables_map options_map;
18
19 try {
20 bop::parsed_options parsed = bop::command_line_parser(argc, argv).options(options_description).allow_unregistered().run();
21
22 // This is to properly catch any positional argument (not supported)
23 const auto& unknown = bop::collect_unrecognized(parsed.options, bop::include_positional);
24 if(unknown.size() != 0) {
25 std::cerr << "Incorrect command line argument, unrecognized options: ";
26 for(const auto& o : unknown) {
27 std::cerr << o << " ";
28 }
29 std::cerr << std::endl;
30
31 return EXIT_FAILURE;
32 }
33
34 bop::store(parsed, options_map);
35 bop::notify(options_map);
36
37 auto display_help_message = [&options_description]()
38 {
39 std::cout
40 << "TDAQ online database schema editor"
41 << std::endl
42 << std::endl
43 << "Usage: schemaeditor [options]"
44 << std::endl
45 << std::endl
46 << options_description
47 << std::endl;
48 };
49
50 if(options_map.count("help")) {
51 display_help_message();
52 return EXIT_SUCCESS;
53 }
54 }
55 catch(std::exception const & e) {
56 std::cerr << "Incorrect command line argument: " << e.what() << std::endl;
57 return EXIT_FAILURE;
58 }
59
60
61 QApplication a(argc, argv);
62
63 dbse::SchemaMainWindow w(QString::fromStdString(oksfn));
64
65 w.show();
66
67 return a.exec();
68}