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

Last change on this file since 11179 was 10646, checked in by tbretz, 14 years ago
Initialize DIM's environment variables through Dim::Setup
File size: 2.1 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 catch (std::exception &e)
57 {
58#if BOOST_VERSION > 104000
59 po::multiple_occurrences *MO = dynamic_cast<po::multiple_occurrences*>(&e);
60 if (MO)
61 cout << "Error: " << e.what() << " of '" << MO->get_option_name() << "' option." << endl;
62 else
63#endif
64 cout << "Error: " << e.what() << endl;
65 cout << endl;
66
67 return -1;
68 }
69
70 if (conf.HasPrint())
71 return -1;
72
73 if (conf.HasVersion())
74 {
75 FACT::PrintVersion(argv[0]);
76 return -1;
77 }
78
79 if (conf.HasHelp())
80 {
81 PrintHelp();
82 return -1;
83 }
84
85 Dim::Setup(conf.Get<string>("dns"));
86
87 QApplication app(argc, const_cast<char**>(argv));
88
89 FactGui gui;
90 gui.show();
91
92 return app.exec();
93}
Note: See TracBrowser for help on using the repository browser.