lib/types: only show ... in loaOf warning when necessary

This commit is contained in:
Jan Tojnar 2020-01-11 13:32:30 +01:00
parent b0c2c96cbe
commit 6fc46fbb17
No known key found for this signature in database
GPG key ID: 7FAB2A15F7A607A4

View file

@ -354,6 +354,7 @@ rec {
}; };
option = concatStringsSep "." loc; option = concatStringsSep "." loc;
sample = take 3 def.value; sample = take 3 def.value;
more = lib.optionalString (length def.value > 3) "... ";
list = concatMapStrings (x: ''{ ${nameAttr} = "${x.${nameAttr} or "unnamed"}"; ...} '') sample; list = concatMapStrings (x: ''{ ${nameAttr} = "${x.${nameAttr} or "unnamed"}"; ...} '') sample;
set = concatMapStrings (x: ''${x.${nameAttr} or "unnamed"} = {...}; '') sample; set = concatMapStrings (x: ''${x.${nameAttr} or "unnamed"} = {...}; '') sample;
msg = '' msg = ''
@ -363,10 +364,10 @@ rec {
See https://git.io/fj2zm for more information. See https://git.io/fj2zm for more information.
Do Do
${option} = ${option} =
{ ${set}...} { ${set}${more}}
instead of instead of
${option} = ${option} =
[ ${list}...] [ ${list}${more}]
''; '';
in in
lib.warn msg res lib.warn msg res