Ignore:
Timestamp:
Apr 7, 2011, 10:10:33 AM (9 years ago)
Author:
tbretz
Message:
Changed some output from cout to cerr to avoid it going to man pages cerated with help2man; added --version option, added possibility to add some text in front of the --help option
File:
1 edited

Legend:

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

    r10230 r10296  
    267267#include <iostream>
    268268
     269#include <boost/bind.hpp>
    269270#include <boost/regex.hpp>
    270271//#include <boost/filesystem.hpp>
     
    442443        ("help-database",       "Print available options retreived from the database.")
    443444        ("help-config",         "Print available configuration file options.")
     445        ("version,V",           "Print version information.")
    444446        ("print-all",           "Print all options as parsed from all the different sources.")
    445447        ("print",               "Print options as parsed from the commandline.")
     
    678680//!
    679681//
    680 void Configuration::SetNameMapper(const boost::function1<std::string, std::string> &func)
     682void Configuration::SetNameMapper(const boost::function<std::string(std::string)> &func)
    681683{
    682684    fNameMapper = func;
     
    686688{
    687689    fNameMapper = bind1st(mem_fun(&Configuration::DefaultMapper), this);
     690}
     691
     692void Configuration::SetPrintUsage(const boost::function<void(void)> &func)
     693{
     694    fPrintUsage = func;
     695}
     696
     697void Configuration::SetPrintUsage()
     698{
     699    fPrintUsage = boost::bind(&Configuration::PrintUsage, this);
    688700}
    689701
     
    803815
    804816    if (getfiles.count("help"))
    805         cout << endl << fOptionsCommandline[kVisible] << endl;
     817    {
     818        fPrintUsage();
     819        cout << fOptionsCommandline[kVisible] << endl;
     820    }
    806821    if (getfiles.count("help-config"))
    807         cout << endl << fOptionsConfigfile[kVisible] << endl;
     822        cout << fOptionsConfigfile[kVisible] << endl;
    808823    if (getfiles.count("help-env"))
    809         cout << endl << fOptionsEnvironment[kVisible] << endl;
     824        cout << fOptionsEnvironment[kVisible] << endl;
    810825    if (getfiles.count("help-database"))
    811         cout << endl << fOptionsDatabase[kVisible] << endl;
     826        cout << fOptionsDatabase[kVisible] << endl;
    812827
    813828    // ------------------------ (4) --------------------------
     
    826841    {
    827842        fDefaultFile = getfiles["default"].as<string>();
    828         cout << "Reading configuration from '" << fDefaultFile << "'." << endl;
     843        cerr << "Reading configuration from '" << fDefaultFile << "'." << endl;
    829844    }
    830845
     
    862877    {
    863878        fPriorityFile = getfiles["config"].as<string>();
    864         cout << "Retrieved option from '" << fPriorityFile << "'." << endl;
     879        cerr << "Retrieved option from '" << fPriorityFile << "'." << endl;
    865880    }
    866881
     
    895910    {
    896911        fDatabase = getdatabase["database"].as<string>();
    897         cout << "Retrieving configuration from '" << fDatabase << "'." << endl;
     912        cerr << "Retrieving configuration from '" << fDatabase << "'." << endl;
    898913    }
    899914
Note: See TracChangeset for help on using the changeset viewer.