Index: trunk/FACT++/src/sendcommand.cc
===================================================================
--- trunk/FACT++/src/sendcommand.cc	(revision 10669)
+++ trunk/FACT++/src/sendcommand.cc	(revision 10670)
@@ -2,34 +2,59 @@
 #include <dic.hxx>
 
+#include "FACT.h"
+#include "Dim.h"
 #include "Configuration.h"
 
 using namespace std;
 
-
-
 void SetupConfiguration(Configuration &conf)
 {
-    const string n = conf.GetName()+".log";
-
-    //po::options_description config("Program options");
     po::options_description config("Configuration");
     config.add_options()
-        ("dns",       var<string>("localhost"),  "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)")
-        ("log,l",     var<string>(n), "Write log-file")
-        //("no-dim,d",  po_switch(),    "Disable dim services")
-        //("console,c", var<int>(),     "Use console (0=shell, 1=simple buffered, X=simple unbuffered)")
-        ("dbname",    var<string>(),      "database name for scheduling preview")
+        ("dns",               var<string>("localhost"),  "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)")
+        ("schedule-database", var<string>(),  "Database name for scheduling preview")
         ;
 
+    po::positional_options_description p;
+    p.add("schedule-database", 1); // The first positional options
+
     conf.AddEnv("dns", "DIM_DNS_NODE");
-
     conf.AddOptions(config);
+    conf.SetArgumentPositions(p);
 }
 
+void PrintUsage()
+{
+    cout <<
+        "The triggerschedule triggers the scheduler.\n"
+        "\n"
+        "The default is that the program is started without user intercation. "
+        "All actions are supposed to arrive as DimCommands. Using the -c "
+        "option, a local shell can be initialized. With h or help a short "
+        "help message about the usuage can be brought to the screen.\n"
+        "\n"
+        "Usage: triggerschedule [-c type] [OPTIONS] <schedule-database>\n"
+        "  or:  triggerschedule [OPTIONS] <schedule-database>\n";
+    cout << endl;
+}
 
+void PrintHelp()
+{
+    cout <<
+        "\n"
+        "The method sendCommand(...) will wait for the command to "
+        "be actualy sent to the server and return a completion code "
+        "of:\n"
+        " 1 - if it was successfully sent.\n"
+        " 0 - if it couldn't be delivered.\n "
+        << endl;
+    /* Additional help text which is printed after the configuration
+     options goes here */
+}
 
 int main(int argc, const char* argv[])
 {
     Configuration conf(argv[0]);
+    conf.SetPrintUsage(PrintUsage);
     SetupConfiguration(conf);
 
@@ -53,37 +78,35 @@
     }
 
-    const char* dbname;
-    if (conf.Has("dbname"))
-        dbname = conf.Get<string>("dbname").c_str();
-    else
+    if (conf.HasPrint())
+        return -1;
+
+    if (conf.HasVersion())
     {
-        cout << "Please provide which database you want to use for scheduling using --dbname=<dbname>." << endl;
+        FACT::PrintVersion(argv[0]);
         return -1;
     }
 
+    if (conf.HasHelp())
+    {
+        PrintHelp();
+        return -1;
+    }
 
-    if (conf.HasHelp() || conf.HasPrint())
+    if (!conf.Has("schedule-database"))
+    {
+        cout << "Please provide which database you want to use for scheduling using --schedule-database=<dbname>." << endl;
         return -1;
+    }
 
-    // To allow overwriting of DIM_DNS_NODE set 0 to 1
-    setenv("DIM_DNS_NODE", conf.Get<string>("dns").c_str(), 1);
+    const char* dbname = conf.Get<string>("schedule-database").c_str();
 
-//int main ()
-//{
+    Dim::Setup(conf.Get<string>("dns"));
 
-    int value;
+    const int rc = DimClient::sendCommand("SCHEDULER/SCHEDULE", dbname);
+    if (!rc)
+        cerr << "Sending failed!" << endl;
+    else
+        cout << "Command issued successfully." << endl;
 
-    value = DimClient::sendCommand("SCHEDULER/SCHEDULE", dbname);
-    //value = DimClient::sendCommand("SCHEDULER/SCHEDULE", NULL, 0);
-
-    cout << "\n";
-    cout << " The method sendCommand(...) will wait for the command to be actualy sent to the Server and return a completion code of : " << endl;
-    cout << "                                   1 - if it was successfully sent  " << endl;
-    cout << "                                   0 - if it couldn't be delivered. " << endl;
-
-    cout << "\n";
-    cout << " The completion code is now:       " << value << endl;
-
-    return 0;
-
+    return rc;
 }
