Validate Boolean settings better

This commit is contained in:
Eelco Dolstra 2017-04-13 16:31:28 +02:00
parent 1860070548
commit 0bf34de43b
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -90,7 +90,12 @@ template<> std::string Setting<int>::to_string()
template<> void Setting<bool>::set(const std::string & str) template<> void Setting<bool>::set(const std::string & str)
{ {
value = str == "true" || str == "1"; if (str == "true" || str == "yes" || str == "1")
value = true;
else if (str == "false" || str == "no" || str == "0")
value = false;
else
throw UsageError("Boolean setting '%s' has invalid value '%s'", name, str);
} }
template<> std::string Setting<bool>::to_string() template<> std::string Setting<bool>::to_string()