···
4
-
/* Automatically convert an attribute set to command-line options.
5
+
Automatically convert an attribute set to command-line options.
7
+
This helps protect against malformed command lines and also to reduce
8
+
boilerplate related to command-line construction for simple use cases.
10
+
`toGNUCommandLine` returns a list of nix strings.
6
-
This helps protect against malformed command lines and also to reduce
7
-
boilerplate related to command-line construction for simple use cases.
12
+
`toGNUCommandLineShell` returns an escaped shell string.
19
+
: 1\. Function argument
23
+
: 2\. Function argument
9
-
`toGNUCommandLine` returns a list of nix strings.
10
-
`toGNUCommandLineShell` returns an escaped shell string.
28
+
## `lib.cli.toGNUCommandLineShell` usage example
31
+
cli.toGNUCommandLine {} {
32
+
data = builtins.toJSON { id = 0; };
36
+
url = [ "https://example.com/foo" "https://example.com/bar" ];
42
+
"--data" "{\"id\":0}"
44
+
"--url" "https://example.com/foo"
45
+
"--url" "https://example.com/bar"
13
-
cli.toGNUCommandLine {} {
14
-
data = builtins.toJSON { id = 0; };
18
-
url = [ "https://example.com/foo" "https://example.com/bar" ];
24
-
"--data" "{\"id\":0}"
26
-
"--url" "https://example.com/foo"
27
-
"--url" "https://example.com/bar"
49
+
cli.toGNUCommandLineShell {} {
50
+
data = builtins.toJSON { id = 0; };
54
+
url = [ "https://example.com/foo" "https://example.com/bar" ];
58
+
=> "'-X' 'PUT' '--data' '{\"id\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'";
31
-
cli.toGNUCommandLineShell {} {
32
-
data = builtins.toJSON { id = 0; };
36
-
url = [ "https://example.com/foo" "https://example.com/bar" ];
40
-
=> "'-X' 'PUT' '--data' '{\"id\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'";
options: attrs: lib.escapeShellArgs (toGNUCommandLine options attrs);