source: trunk/FACT++/gui/fact.cc@ 11277

Last change on this file since 11277 was 11230, checked in by tbretz, 13 years ago
Updated initialization process according to the other programs.
File size: 2.0 KB
Line 
1#include "FactGui.h"
2
3#include "src/FACT.h"
4#include "src/Dim.h"
5#include "src/Configuration.h"
6
7/*
8 Extract usage clause(s) [if any] for SYNOPSIS.
9 Translators: "Usage" and "or" here are patterns (regular expressions) which
10 are used to match the usage synopsis in program output. An example from cp
11 (GNU coreutils) which contains both strings:
12 Usage: cp [OPTION]... [-T] SOURCE DEST
13 or: cp [OPTION]... SOURCE... DIRECTORY
14 or: cp [OPTION]... -t DIRECTORY SOURCE...
15 */
16void PrintUsage()
17{
18 cout << "\n"
19 "The FACT++ Graphical User Interfact (GUI).\n"
20 "\n"
21 "Usage: fact [-c type] [OPTIONS]\n"
22 " or: fact [OPTIONS]\n";
23 cout << endl;
24
25}
26
27void PrintHelp()
28{
29 /* Additional help text which is printed after the configuration
30 options goes here */
31}
32
33void SetupConfiguration(Configuration &conf)
34{
35 po::options_description config("Program options");
36 config.add_options()
37 ("dns", var<string>("localhost"), "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)")
38 ;
39
40 conf.AddEnv("dns", "DIM_DNS_NODE");
41
42 conf.AddOptions(config);
43}
44
45int main(int argc, const char* argv[])
46{
47 Configuration conf(argv[0]);
48 conf.SetPrintUsage(PrintUsage);
49 SetupConfiguration(conf);
50
51 po::variables_map vm;
52 try
53 {
54 vm = conf.Parse(argc, argv);
55 }
56#if BOOST_VERSION > 104000
57 catch (po::multiple_occurrences &e)
58 {
59 cerr << "Program options invalid due to: " << e.what() << " of '" << e.get_option_name() << "'." << endl;
60 return -1;
61 }
62#endif
63 catch (exception& e)
64 {
65 cerr << "Program options invalid due to: " << e.what() << endl;
66 return -1;
67 }
68
69 if (conf.HasVersion() || conf.HasPrint())
70 return -1;
71
72 if (conf.HasHelp())
73 {
74 PrintHelp();
75 return -1;
76 }
77
78 Dim::Setup(conf.Get<string>("dns"));
79
80 QApplication app(argc, const_cast<char**>(argv));
81
82 FactGui gui;
83 gui.show();
84
85 return app.exec();
86}
Note: See TracBrowser for help on using the repository browser.