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

Last change on this file since 11577 was 11576, checked in by tbretz, 14 years ago
Added host option.
File size: 2.2 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 (overwites DIM_DNS_NODE environment variable)")
38 ("host", var<string>(""), "Address with which the Dim nameserver can connect to this host (overwites DIM_HOST_NODE environment variable)")
39 ;
40
41 conf.AddEnv("dns", "DIM_DNS_NODE");
42 conf.AddEnv("dns", "DIM_HOST_NODE");
43
44 conf.AddOptions(config);
45}
46
47int main(int argc, const char* argv[])
48{
49 Configuration conf(argv[0]);
50 conf.SetPrintUsage(PrintUsage);
51 SetupConfiguration(conf);
52
53 po::variables_map vm;
54 try
55 {
56 vm = conf.Parse(argc, argv);
57 }
58#if BOOST_VERSION > 104000
59 catch (po::multiple_occurrences &e)
60 {
61 cerr << "Program options invalid due to: " << e.what() << " of '" << e.get_option_name() << "'." << endl;
62 return -1;
63 }
64#endif
65 catch (exception& e)
66 {
67 cerr << "Program options invalid due to: " << e.what() << endl;
68 return -1;
69 }
70
71 if (conf.HasVersion() || conf.HasPrint())
72 return -1;
73
74 if (conf.HasHelp())
75 {
76 PrintHelp();
77 return -1;
78 }
79
80 Dim::Setup(conf.Get<string>("dns"), conf.Get<string>("host"));
81
82 QApplication app(argc, const_cast<char**>(argv));
83
84 FactGui gui;
85 gui.show();
86
87 const int rc = app.exec();
88
89 cout << "The end." << endl;
90
91 return rc;
92}
Note: See TracBrowser for help on using the repository browser.