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

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

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));
}}
});
};