summaryrefslogtreecommitdiff
path: root/project2/basics/options/showHelp.cpp
blob: feabd45a28cf378d6e0bd4d2b464b54fddaaa26c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "showHelp.h"
#include <options.h>
#include <boost/bind.hpp>
#include <boost/foreach.hpp>

void ShowHelpComponent::onConfigLoad()
{
	if (!showHelp)
		return;
	fprintf(stdout, "Help\n");
	InstanceSet<Options>::OnAll(boost::bind(&ShowHelpComponent::outputOptions, this, _1));
	exit(1);
}

void ShowHelpComponent::outputOptions(const Options * options) const
{
	fprintf(stdout, "  * %s\n", options->name.c_str());
	BOOST_FOREACH(const auto & option, options->allOptions()) {
		fprintf(stdout, "    * %s - %s\n", option->name().c_str(), option->description().c_str());
	}
}

bool ShowHelpComponent::showHelp;
DECLARE_COMPONENT("ShowHelpComponent", ShowHelpComponent);