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

Last change on this file since 12994 was 12993, checked in by tbretz, 13 years ago
Fixed an issue with the console and shell selection.
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
27 Main::PrintUsage();
28 cout << endl;
29}
30
31void PrintHelp()
32{
33}
34
35// A simple dummy state machine
36class DimCtrl : public MainImp, public MessageImp
37{
38 bool fStop;
39
40public:
41 DimCtrl(ostream &out=cout) : MessageImp(out), fStop(false)
42 {
43 }
44
45 int EvalOptions(Configuration &) { return -1; }
46 void Stop() { fStop = true; }
47 int Run(bool) { while (!fStop) usleep(1000); return 0; }
48};
49
50int main(int argc, const char *argv[])
51{
52 Configuration conf(argv[0]);
53 conf.SetPrintUsage(PrintUsage);
54 Main::SetupConfiguration(conf);
55
56 if (!conf.DoParse(argc, argv, PrintHelp))
57 return -1;
58
59 if (!conf.Has("console") || conf.Get<int>("console")==0)
60 return Main::execute<RemoteShell, DimCtrl>(conf);
61 else
62 return Main::execute<RemoteConsole, DimCtrl>(conf);
63
64 return 0;
65}
Note: See TracBrowser for help on using the repository browser.