summaryrefslogtreecommitdiffstats
path: root/lib/cli.nix
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2020-01-22 23:55:42 +0100
committerProfpatsch <mail@profpatsch.de>2020-01-23 14:47:38 +0100
commite71e1be8590e0f0dcac66e8b1e09695b94362fbd (patch)
tree71a8be7b5c7de36a1929a23869c3d22bc8c9cd56 /lib/cli.nix
parentb2654c226a83aa4cf5948f04ea6370796a2c7055 (diff)
lib/cli: rename `renderX` options to `mkX`
Mirrors the naming scheme in `generators.nix`, for consistency. Also rename `key` to `k` and value to `v` to aid readability to the code structure.
Diffstat (limited to 'lib/cli.nix')
-rw-r--r--lib/cli.nix31
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/cli.nix b/lib/cli.nix
index a0e85c396057..067ee21696ab 100644
--- a/lib/cli.nix
+++ b/lib/cli.nix
@@ -43,29 +43,26 @@ rec {
options: attrs: lib.escapeShellArgs (toGNUCommandLine options attrs);
toGNUCommandLine =
- { renderKey ?
- key:
- if builtins.stringLength key == 1
- then "-${key}"
- else "--${key}"
+ { mkKey ?
+ k: if builtins.stringLength k == 1
+ then "-${k}"
+ else "--${k}"
- , renderOption ?
- key: value:
- if value == null
- then []
- else [ (renderKey key) (builtins.toString value) ]
+ , mkOption ?
+ k: v: if v == null
+ then []
+ else [ (mkKey k) (builtins.toString v) ]
- , renderBool ? key: value: lib.optional value (renderKey key)
+ , mkBool ? k: v: lib.optional v (mkKey k)
- , renderList ? key: value: lib.concatMap (renderOption key) value
+ , mkList ? k: v: lib.concatMap (mkOption k) v
}:
options:
let
- render =
- key: value:
- if builtins.isBool value then renderBool key value
- else if builtins.isList value then renderList key value
- else renderOption key value;
+ render = k: v:
+ if builtins.isBool v then mkBool k v
+ else if builtins.isList v then mkList k v
+ else mkOption k v;
in
builtins.concatLists (lib.mapAttrsToList render options);