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:
parent
d8d20307a8
commit
79c7d6205c
4 changed files with 19 additions and 6 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue