Remove mkFlag integer specialisation
This commit is contained in:
parent
48a9be2aab
commit
1d4954e73e
2 changed files with 13 additions and 21 deletions
|
@ -211,9 +211,19 @@ LegacyArgs::LegacyArgs(const std::string & programName,
|
||||||
});
|
});
|
||||||
|
|
||||||
auto intSettingAlias = [&](char shortName, const std::string & longName,
|
auto intSettingAlias = [&](char shortName, const std::string & longName,
|
||||||
const std::string & description, const std::string & dest) {
|
const std::string & description, const std::string & dest)
|
||||||
mkFlag<unsigned int>(shortName, longName, description, [=](unsigned int n) {
|
{
|
||||||
|
addFlag({
|
||||||
|
.longName = longName,
|
||||||
|
.shortName = shortName,
|
||||||
|
.description = description,
|
||||||
|
.labels = {"n"},
|
||||||
|
.handler = {[=](std::string s) {
|
||||||
|
unsigned int n;
|
||||||
|
if (!string2Int(s, n))
|
||||||
|
throw UsageError("'%s' is not an integer", s);
|
||||||
settings.set(dest, std::to_string(n));
|
settings.set(dest, std::to_string(n));
|
||||||
|
}}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -174,24 +174,6 @@ public:
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class I>
|
|
||||||
void mkFlag(char shortName, const std::string & longName,
|
|
||||||
const std::string & description, std::function<void(I)> fun)
|
|
||||||
{
|
|
||||||
addFlag({
|
|
||||||
.longName = longName,
|
|
||||||
.shortName = shortName,
|
|
||||||
.description = description,
|
|
||||||
.labels = {"N"},
|
|
||||||
.handler = {[=](std::string s) {
|
|
||||||
I n;
|
|
||||||
if (!string2Int(s, n))
|
|
||||||
throw UsageError("flag '--%s' requires a integer argument", longName);
|
|
||||||
fun(n);
|
|
||||||
}}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void expectArgs(ExpectedArg && arg)
|
void expectArgs(ExpectedArg && arg)
|
||||||
{
|
{
|
||||||
expectedArgs.emplace_back(std::move(arg));
|
expectedArgs.emplace_back(std::move(arg));
|
||||||
|
|
Loading…
Reference in a new issue