13 namespace fs = boost::filesystem;
18 #if BOOST_VERSION < 104600 19 const string fname = fs::path(conf.
GetName()).filename();
21 const string fname = fs::path(conf.
GetName()).filename().string();
25 return Main::execute<T, StateMachineDimControl>(conf);
30 #if BOOST_VERSION < 104600 31 const string fname = fs::path(conf.
GetName()).filename();
33 const string fname = fs::path(conf.
GetName()).filename().string();
36 po::options_description control(
"Options ("+fname+
")");
38 (
"force-console",
po_switch(),
"Forces console mode in server-mode.")
39 (
"debug",
po_bool(
false),
"Print the labels for debugging purpose")
40 (
"user,u", var<string>(
""),
"A user name - just for logging purposes (default is ${USER})")
41 (
"JavaScript.*", var<string>(),
"Additional arguments which are provided to JavaScripts started in a dimctrl server via the START command")
44 if (fname!=
"dimserver")
47 (
"batch", var<string>(),
"Start a batch script with the given name at the given label (script.dim[:N]) on the dimctrl-server")
48 (
"start", var<string>(),
"Start a java script with the given name on the dimctrl-server")
49 (
"stop",
po_switch(),
"Stop a currently running script on the dimctrl-server")
50 (
"interrupt", var<string>()->implicit_value(
""),
"Send an interrupt request (IRQ) to a running JavaScript.")
51 (
"restart", var<string>(),
"Send 'EXIT 126' to the given server")
52 (
"msg", var<string>(),
"Send a message to the chat server.")
56 conf.
AddEnv(
"user",
"USER");
73 "The dim control is a central master for the dim network.\n" 75 "The program can be started as a dim server, so that it is visible " 76 "in the dim network to other clients. If started as a client (dimctrl), " 77 "it can only interact passively with the dim network. The usual case " 78 "should be to have one server running (dimserver) and control it from " 79 "a dimctrl started.\n" 81 "Usage: dimctrl [-c type] [OPTIONS]\n" 82 " or: dimctrl [OPTIONS]\n" 83 " or: dimserver [OPTIONS]\n";
89 Main::PrintHelp<StateMachineDimControl>();
109 int main(
int argc,
const char* argv[])
121 if (conf.
Get<
bool>(
"force-console") && !conf.
Has(
"console"))
122 throw runtime_error(
"--force-console must be used with --console/-c");
124 #if BOOST_VERSION < 104600 125 const string fname = fs::path(conf.
GetName()).filename();
127 const string fname = fs::path(conf.
GetName()).filename().string();
130 if (fname==
"dimserver" && !conf.
Get<
bool>(
"force-console"))
133 if (!conf.
Has(
"console"))
134 return RunShell<RemoteStream>(conf);
136 if (conf.
Get<
int>(
"console")==0)
137 return RunShell<RemoteShell>(conf);
139 return RunShell<RemoteConsole>(conf);
void SetupConfiguration(Configuration &conf)
void SetPrintUsage(const std::function< void(void)> &func)
T Get(const std::string &var)
po::typed_value< bool > * po_switch()
void AddEnv(const std::string &conf, const std::string &env)
void Remove(const std::string &var)
int main(int argc, const char *argv[])
bool Has(const std::string &var)
void AddOptions(const po::options_description &opt, bool visible=true)
int RunShell(Configuration &conf)
Commandline parsing, resource file parsing and database access.
po::typed_value< bool > * po_bool(bool def=false)
void SetupConfiguration(Configuration &conf)
bool DoParse(int argc, const char **argv, const std::function< void()> &func=std::function< void()>())
const std::string & GetName() const