Changeset 10392


Ignore:
Timestamp:
Apr 18, 2011, 2:36:46 PM (9 years ago)
Author:
tbretz
Message:
Adapted the order in the call for the constructor of Description; added the 'standard way of priting usage and help informations'
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/dataLogger.cc

    r10377 r10392  
    890890         
    891891        //Init the time columns of the file
    892         Description dateDesc(std::string("Time"), std::string("MjD"), std::string("Modified Julian Date"));
     892        Description dateDesc(std::string("Time"), std::string("Modified Julian Date"), std::string("MjD"));
    893893        sub.dailyFile.AddStandardColumn(dateDesc, "1D", &fMjD, sizeof(double));
    894894        sub.runFile.AddStandardColumn(dateDesc, "1D", &fMjD, sizeof(double));
    895895
    896         Description QoSDesc("Qos", "None", "Quality of service");
     896        Description QoSDesc("Qos", "Quality of service", "None");
    897897        sub.dailyFile.AddStandardColumn(QoSDesc, "1J", &fQuality, sizeof(int));
    898898        sub.runFile.AddStandardColumn(QoSDesc, "1J", &fQuality, sizeof(int));
     
    11031103}
    11041104
     1105/*
     1106 Extract usage clause(s) [if any] for SYNOPSIS.
     1107 Translators: "Usage" and "or" here are patterns (regular expressions) which
     1108 are used to match the usage synopsis in program output.  An example from cp
     1109 (GNU coreutils) which contains both strings:
     1110  Usage: cp [OPTION]... [-T] SOURCE DEST
     1111    or:  cp [OPTION]... SOURCE... DIRECTORY
     1112    or:  cp [OPTION]... -t DIRECTORY SOURCE...
     1113 */
     1114void PrintUsage()
     1115{
     1116    cout << "\n"
     1117        "The data logger connects to all available Dim services and "
     1118        "writes them to ascii and fits files.\n"
     1119        "\n"
     1120        "Usage: dataLogger [-c type] [OPTIONS]\n"
     1121        "  or:  dataLogger [OPTIONS]\n"
     1122        "\n"
     1123        "Options:\n"
     1124        "The following describes the available commandline options. "
     1125        "For further details on how command line option are parsed "
     1126        "and in which order which configuration sources are accessed "
     1127        "please refer to the class reference of the Configuration class.";
     1128    cout << endl;
     1129
     1130}
     1131
     1132void PrintHelp()
     1133{
     1134    cout << "\n"
     1135        "The default is that the program is started without user interaction. "
     1136        "All actions are supposed to arrive as DimCommands. Using the -c "
     1137        "option, a local shell can be initialized. With h or help a short "
     1138        "help message about the usuage can be brought to the screen."
     1139        << endl;
     1140
     1141    /*
     1142     cout << "bla bla bla" << endl << endl;
     1143     cout << endl;
     1144     cout << "Environment:" << endl;
     1145     cout << "environment" << endl;
     1146     cout << endl;
     1147     cout << "Examples:" << endl;
     1148     cout << "test exam" << endl;
     1149     cout << endl;
     1150     cout << "Files:" << endl;
     1151     cout << "files" << endl;
     1152     cout << endl;
     1153     */
     1154}
     1155
     1156/*
     1157 The first line of the --version information is assumed to be in one
     1158 of the following formats:
     1159
     1160   <version>
     1161   <program> <version>
     1162   {GNU,Free} <program> <version>
     1163   <program> ({GNU,Free} <package>) <version>
     1164   <program> - {GNU,Free} <package> <version>
     1165
     1166 and separated from any copyright/author details by a blank line.
     1167
     1168 Handle multi-line bug reporting sections of the form:
     1169
     1170   Report <program> bugs to <addr>
     1171   GNU <package> home page: <url>
     1172   ...
     1173*/
     1174void PrintVersion(const char *name)
     1175{
     1176    cout <<
     1177        name << " - FACT++ 1.0\n"
     1178        "\n"
     1179        "Written by Thomas Bretz <thomas.bretz@epfl.ch> et al.\n"
     1180        "\n"
     1181        "Report bugs to Thomas Bretz <thomas.bretz@epfl.ch>\n"
     1182        "FACT++ home page: http://www.xxx.com\n"
     1183        "\n"
     1184        "Copyright (C) 2011 by the FACT Collaboration.\n"
     1185        "This is free software; see the source for copying conditions.\n"
     1186        << endl;
     1187}
     1188
     1189
    11051190void SetupConfiguration(Configuration &conf)
    11061191{
    1107     const std::string n = conf.GetName()+".log";
     1192    const string n = conf.GetName()+".log";
    11081193
    11091194    po::options_description config("Program options");
    11101195    config.add_options()
    1111         ("dns",       var<std::string>("localhost"),       "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)")
    1112         ("log,l",     var<std::string>(n), "Write log-file")
     1196        ("dns",       var<string>("localhost"),  "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)")
     1197        ("log,l",     var<string>(n), "Write log-file")
    11131198        ("console,c", var<int>(),     "Use console (0=shell, 1=simple buffered, X=simple unbuffered)")
    11141199        ;
     
    11221207{
    11231208    Configuration conf(argv[0]);
     1209    conf.SetPrintUsage(PrintUsage);
    11241210    SetupConfiguration(conf);
    11251211
     
    11291215        vm = conf.Parse(argc, argv);
    11301216    }
     1217    catch (std::exception &e)
     1218    {
    11311219#if BOOST_VERSION > 104000
    1132     catch (po::multiple_occurrences &e)
    1133     {
    1134         std::cout << "Error: " << e.what() << " of '" << e.get_option_name() << "' option." << std::endl;
    1135         std::cout << std::endl;
     1220        po::multiple_occurrences *MO = dynamic_cast<po::multiple_occurrences*>(&e);
     1221        if (MO)
     1222            cout << "Error: " << e.what() << " of '" << MO->get_option_name() << "' option." << endl;
     1223        else
     1224#endif
     1225            cout << "Error: " << e.what() << endl;
     1226        cout << endl;
     1227
    11361228        return -1;
    11371229    }
    1138 #endif
    1139     catch (std::exception &e)
     1230
     1231    if (conf.HasPrint())
     1232        return -1;
     1233
     1234    if (conf.HasVersion())
    11401235    {
    1141         std::cout << "Error: " << e.what() << std::endl;
    1142         std::cout << std::endl;
    1143 
     1236        PrintVersion(argv[0]);
    11441237        return -1;
    11451238    }
    11461239
    1147     if (conf.HasHelp() || conf.HasPrint())
     1240    if (conf.HasHelp())
     1241    {
     1242        PrintHelp();
    11481243        return -1;
     1244    }
    11491245
    11501246    setenv("DIM_DNS_NODE", conf.Get<string>("dns").c_str(), 1);
Note: See TracChangeset for help on using the changeset viewer.