source: trunk/FACT++/src/dimctrl.cc@ 13445

Last change on this file since 13445 was 13006, checked in by tbretz, 13 years ago
Reformated the output to make it better fit the help2man conversion.
File size: 1.6 KB
Line 
1#include "RemoteControl.h"
2#include "Main.h"
3
4using namespace std;
5
6// ========================================================================
7
8
9/*
10 Extract usage clause(s) [if any] for SYNOPSIS.
11 Translators: "Usage" and "or" here are patterns (regular expressions) which
12 are used to match the usage synopsis in program output. An example from cp
13 (GNU coreutils) which contains both strings:
14 Usage: cp [OPTION]... [-T] SOURCE DEST
15 or: cp [OPTION]... SOURCE... DIRECTORY
16 or: cp [OPTION]... -t DIRECTORY SOURCE...
17 */
18void PrintUsage()
19{
20 cout << "\n"
21 "The console connects to all available Dim Servers and allows to "
22 "easily access all of their commands.\n"
23 "\n"
24 "Usage: dimctrl [-c type] [OPTIONS]\n"
25 " or: dimctrl [OPTIONS]\n\n";
26 cout << endl;
27}
28
29void PrintHelp()
30{
31 Main::PrintUsage();
32}
33
34// A simple dummy state machine
35class DimCtrl : public MainImp, public MessageImp
36{
37 bool fStop;
38
39public:
40 DimCtrl(ostream &out=cout) : MessageImp(out), fStop(false)
41 {
42 }
43
44 int EvalOptions(Configuration &) { return -1; }
45 void Stop() { fStop = true; }
46 int Run(bool) { while (!fStop) usleep(1000); return 0; }
47};
48
49int main(int argc, const char *argv[])
50{
51 Configuration conf(argv[0]);
52 conf.SetPrintUsage(PrintUsage);
53 Main::SetupConfiguration(conf);
54
55 if (!conf.DoParse(argc, argv, PrintHelp))
56 return -1;
57
58 if (!conf.Has("console") || conf.Get<int>("console")==0)
59 return Main::execute<RemoteShell, DimCtrl>(conf);
60 else
61 return Main::execute<RemoteConsole, DimCtrl>(conf);
62
63 return 0;
64}
Note: See TracBrowser for help on using the repository browser.