Name argument of option's merge functions are now obsolete.
svn path=/nixpkgs/trunk/; revision=13842
This commit is contained in:
parent
daa6f9c7ef
commit
c1b9946c28
@ -477,7 +477,7 @@ rec {
|
|||||||
}
|
}
|
||||||
) (builtins.attrNames defs));
|
) (builtins.attrNames defs));
|
||||||
|
|
||||||
mergeDefaultOption = name: list:
|
mergeDefaultOption = list:
|
||||||
if list != [] && tail list == [] then head list
|
if list != [] && tail list == [] then head list
|
||||||
else if all __isFunction list then x: mergeDefaultOption (map (f: f x) list)
|
else if all __isFunction list then x: mergeDefaultOption (map (f: f x) list)
|
||||||
else if all __isList list then concatLists list
|
else if all __isList list then concatLists list
|
||||||
@ -486,7 +486,7 @@ rec {
|
|||||||
else if all (x: x == toString x) list then concatStrings list
|
else if all (x: x == toString x) list then concatStrings list
|
||||||
else throw "Cannot merge values.";
|
else throw "Cannot merge values.";
|
||||||
|
|
||||||
mergeTypedOption = typeName: predicate: merge: name: list:
|
mergeTypedOption = typeName: predicate: merge: list:
|
||||||
if all predicate list then merge list
|
if all predicate list then merge list
|
||||||
else throw "Expect a ${typeName}.";
|
else throw "Expect a ${typeName}.";
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ rec {
|
|||||||
(x: if builtins ? isString then builtins.isString x else x + "")
|
(x: if builtins ? isString then builtins.isString x else x + "")
|
||||||
concatStrings;
|
concatStrings;
|
||||||
|
|
||||||
mergeOneOption = name: list:
|
mergeOneOption = list:
|
||||||
if list == [] then abort "This case should never happens."
|
if list == [] then abort "This case should never happens."
|
||||||
else if tail list != [] then throw "Multiple definitions. Only one is allowed for this option."
|
else if tail list != [] then throw "Multiple definitions. Only one is allowed for this option."
|
||||||
else head list;
|
else head list;
|
||||||
@ -556,13 +556,24 @@ rec {
|
|||||||
# function of each option to get the result.
|
# function of each option to get the result.
|
||||||
mergeOptionSets = noOption: newMergeOptionSets; # ignore argument
|
mergeOptionSets = noOption: newMergeOptionSets; # ignore argument
|
||||||
newMergeOptionSets =
|
newMergeOptionSets =
|
||||||
|
let
|
||||||
|
# handle merge functions with & without name argument.
|
||||||
|
mergeWrapper = merge: name: values:
|
||||||
|
let
|
||||||
|
newMerge = merge values;
|
||||||
|
oldMerge = builtins.trace
|
||||||
|
"obsolete: Merge function of ${name} option has name argument."
|
||||||
|
(merge name values);
|
||||||
|
in
|
||||||
|
if __isFunction newMerge then oldMerge else newMerge;
|
||||||
|
in
|
||||||
handleOptionSets {
|
handleOptionSets {
|
||||||
export = opt: values:
|
export = opt: values:
|
||||||
opt.apply (
|
opt.apply (
|
||||||
if values == [] then
|
if values == [] then
|
||||||
if opt ? default then opt.default
|
if opt ? default then opt.default
|
||||||
else throw "Not defined."
|
else throw "Not defined."
|
||||||
else opt.merge (opt.name) values
|
else mergeWrapper opt.merge opt.name values
|
||||||
);
|
);
|
||||||
notHandle = throw "Used without option declaration.";
|
notHandle = throw "Used without option declaration.";
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user