public static Func <string, T, T> BuildWithDefaultValue <T>(ICakeArguments arguments, ICakeEnvironment environment, string prefix) { ValidateParams(arguments, environment, prefix); return((paramName, defaultValue) => { var paramValue = GetValue(arguments, environment, prefix, paramName); return paramValue != null?TypeConverter.ConvertTo <T>(paramValue) : defaultValue; }); }
public static Func <string, T> BuildRequired <T>(ICakeArguments arguments, ICakeEnvironment environment, string prefix) { ValidateParams(arguments, environment, prefix); return(paramName => { var paramValue = GetValue(arguments, environment, prefix, paramName); return paramValue != null ? TypeConverter.ConvertTo <T>(paramValue) : throw new CakeException($"Argument '{paramName}' or environment variable '{GetEnvVarName(prefix, paramName)}' were not set."); }); }