toGNUCommandLineShell
lib.cli.toGNUCommandLineShell
Docs pulled from | This Revision | about 3 hours ago
Automatically convert an attribute set to command-line options.
This helps protect against malformed command lines and also to reduce boilerplate related to command-line construction for simple use cases.
toGNUCommandLineShell
returns an escaped shell string.
Inputs
options
-
How to format the arguments, see
toGNUCommandLine
attrs
-
The attributes to transform into arguments.
Examples
lib.cli.toGNUCommandLineShell
usage example
cli.toGNUCommandLineShell {} {
data = builtins.toJSON { id = 0; };
X = "PUT";
retry = 3;
retry-delay = null;
url = [ "https://example.com/foo" "https://example.com/bar" ];
silent = false;
verbose = true;
}
=> "'-X' 'PUT' '--data' '{\"id\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'";
Noogle detected
Implementation
The following is the current implementation of this function.
toGNUCommandLineShell = options: attrs: lib.escapeShellArgs (toGNUCommandLine options attrs);