diff --git a/lix/libutil/config-impl.hh b/lix/libutil/config-impl.hh index d25ec5fd1..7c9a5aa1e 100644 --- a/lix/libutil/config-impl.hh +++ b/lix/libutil/config-impl.hh @@ -127,6 +127,7 @@ void BaseSetting::convertToArg(Args & args, const std::string & category) DECLARE_CONFIG_SERIALISER(std::string) DECLARE_CONFIG_SERIALISER(std::optional) DECLARE_CONFIG_SERIALISER(std::optional) +DECLARE_CONFIG_SERIALISER(std::optional) DECLARE_CONFIG_SERIALISER(bool) DECLARE_CONFIG_SERIALISER(Strings) DECLARE_CONFIG_SERIALISER(StringSet) diff --git a/lix/libutil/config.cc b/lix/libutil/config.cc index fe0be4408..3948eee94 100644 --- a/lix/libutil/config.cc +++ b/lix/libutil/config.cc @@ -181,11 +181,30 @@ template<> std::optional BaseSetting>::parse(c throw UsageError("setting '%s' has invalid value '%s'", name, str); } +template<> +std::optional +BaseSetting>::parse(const std::string & str, const ApplyConfigOptions & options) const +{ + if (str == "") { + return std::nullopt; + } else if (auto n = string2Int(str)) { + return n; + } else { + throw UsageError("setting '%s' has invalid value '%s'", name, str); + } +} + template<> std::string BaseSetting>::to_string() const { return value ? std::to_string(*value) : ""; } +template<> +std::string BaseSetting>::to_string() const +{ + return value ? std::to_string(*value) : ""; +} + template<> bool BaseSetting::parse(const std::string & str, const ApplyConfigOptions & options) const { if (str == "true" || str == "yes" || str == "1")