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

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