mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-19 00:46:03 +01:00
added --define option
This commit is contained in:
parent
d6f97fe346
commit
19228eedd9
@ -144,20 +144,27 @@ protected:
|
||||
Application::defineOptions(options);
|
||||
|
||||
options.addOption(
|
||||
Option("help", "h", "display help information on command line arguments")
|
||||
Option("help", "h", "Display help information on command line arguments.")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.callback(OptionCallback<PocoDocApp>(this, &PocoDocApp::handleHelp)));
|
||||
|
||||
options.addOption(
|
||||
Option("config", "f", "load configuration data from a file")
|
||||
Option("config", "f", "Load configuration data from a file.")
|
||||
.required(false)
|
||||
.repeatable(true)
|
||||
.argument("file")
|
||||
.callback(OptionCallback<PocoDocApp>(this, &PocoDocApp::handleConfig)));
|
||||
|
||||
options.addOption(
|
||||
Option("eclipse", "e", "write Eclipse TOC file")
|
||||
Option("define", "D", "Define a configuration property.")
|
||||
.required(false)
|
||||
.repeatable(true)
|
||||
.argument("name=value")
|
||||
.callback(OptionCallback<PocoDocApp>(this, &PocoDocApp::handleDefine)));
|
||||
|
||||
options.addOption(
|
||||
Option("eclipse", "e", "Write Eclipse TOC file.")
|
||||
.required(false)
|
||||
.repeatable(false)
|
||||
.callback(OptionCallback<PocoDocApp>(this, &PocoDocApp::handleEclipse)));
|
||||
@ -170,6 +177,25 @@ protected:
|
||||
stopOptionsProcessing();
|
||||
}
|
||||
|
||||
void handleDefine(const std::string& name, const std::string& value)
|
||||
{
|
||||
defineProperty(value);
|
||||
}
|
||||
|
||||
void defineProperty(const std::string& def)
|
||||
{
|
||||
std::string name;
|
||||
std::string value;
|
||||
std::string::size_type pos = def.find('=');
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
name.assign(def, 0, pos);
|
||||
value.assign(def, pos + 1, def.length() - pos);
|
||||
}
|
||||
else name = def;
|
||||
config().setString(name, value);
|
||||
}
|
||||
|
||||
void handleEclipse(const std::string& name, const std::string& value)
|
||||
{
|
||||
_writeEclipseTOC = true;
|
||||
@ -185,7 +211,7 @@ protected:
|
||||
HelpFormatter helpFormatter(options());
|
||||
helpFormatter.setCommand(commandName());
|
||||
helpFormatter.setUsage("OPTIONS");
|
||||
helpFormatter.setHeader("Applied Informatics' super duper documentation builder.");
|
||||
helpFormatter.setHeader("POCO C++ Libraries documentation builder.");
|
||||
helpFormatter.format(std::cout);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user