1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 04:21:16 +02:00

Remove mkFlag integer specialisation

This commit is contained in:
Eelco Dolstra 2021-01-08 11:40:36 +01:00
parent 48a9be2aab
commit 1d4954e73e
2 changed files with 13 additions and 21 deletions

View file

@ -211,9 +211,19 @@ LegacyArgs::LegacyArgs(const std::string & programName,
});
auto intSettingAlias = [&](char shortName, const std::string & longName,
const std::string & description, const std::string & dest) {
mkFlag<unsigned int>(shortName, longName, description, [=](unsigned int n) {
settings.set(dest, std::to_string(n));
const std::string & description, const std::string & dest)
{
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));
}}
});
};