Support binary unit prefixes in command line arguments

This commit is contained in:
Eelco Dolstra
2021-01-08 12:51:19 +01:00
parent 6548b89cc4
commit 17beae299d
4 changed files with 29 additions and 27 deletions
+2 -4
View File
@@ -219,10 +219,8 @@ LegacyArgs::LegacyArgs(const std::string & programName,
.description = description,
.labels = {"n"},
.handler = {[=](std::string s) {
if (auto n = string2Int<unsigned int>(s))
settings.set(dest, std::to_string(*n));
else
throw UsageError("'%s' is not an integer", s);
auto n = string2IntWithUnitPrefix<uint64_t>(s);
settings.set(dest, std::to_string(n));
}}
});
};