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

Support unit prefixes in configuration settings

E.g. you can now say `--min-free 1G`.
This commit is contained in:
Eelco Dolstra 2023-02-16 15:16:30 +01:00
parent d8d20307a8
commit 79c7d6205c
4 changed files with 19 additions and 6 deletions

View file

@ -116,10 +116,11 @@ T BaseSetting<T>::parse(const std::string & str) const
{
static_assert(std::is_integral<T>::value, "Integer required.");
if (auto n = string2Int<T>(str))
return *n;
else
try {
return string2IntWithUnitPrefix<T>(str);
} catch (...) {
throw UsageError("setting '%s' has invalid value '%s'", name, str);
}
}
template<typename T>