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 14 of file SchemaMain.cpp.

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