doc: migrate lib.cli to use doc-comments
This commit is contained in:
parent
284dd64382
commit
6bcb2b90ed
1 changed files with 54 additions and 33 deletions
25
lib/cli.nix
25
lib/cli.nix
|
@ -1,15 +1,33 @@
|
||||||
{ lib }:
|
{ lib }:
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
/* Automatically convert an attribute set to command-line options.
|
/**
|
||||||
|
Automatically convert an attribute set to command-line options.
|
||||||
|
|
||||||
This helps protect against malformed command lines and also to reduce
|
This helps protect against malformed command lines and also to reduce
|
||||||
boilerplate related to command-line construction for simple use cases.
|
boilerplate related to command-line construction for simple use cases.
|
||||||
|
|
||||||
`toGNUCommandLine` returns a list of nix strings.
|
`toGNUCommandLine` returns a list of nix strings.
|
||||||
|
|
||||||
`toGNUCommandLineShell` returns an escaped shell string.
|
`toGNUCommandLineShell` returns an escaped shell string.
|
||||||
|
|
||||||
Example:
|
|
||||||
|
# Inputs
|
||||||
|
|
||||||
|
`options`
|
||||||
|
|
||||||
|
: 1\. Function argument
|
||||||
|
|
||||||
|
`attrs`
|
||||||
|
|
||||||
|
: 2\. Function argument
|
||||||
|
|
||||||
|
|
||||||
|
# Examples
|
||||||
|
:::{.example}
|
||||||
|
## `lib.cli.toGNUCommandLineShell` usage example
|
||||||
|
|
||||||
|
```nix
|
||||||
cli.toGNUCommandLine {} {
|
cli.toGNUCommandLine {} {
|
||||||
data = builtins.toJSON { id = 0; };
|
data = builtins.toJSON { id = 0; };
|
||||||
X = "PUT";
|
X = "PUT";
|
||||||
|
@ -38,6 +56,9 @@ rec {
|
||||||
verbose = true;
|
verbose = true;
|
||||||
}
|
}
|
||||||
=> "'-X' 'PUT' '--data' '{\"id\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'";
|
=> "'-X' 'PUT' '--data' '{\"id\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'";
|
||||||
|
```
|
||||||
|
|
||||||
|
:::
|
||||||
*/
|
*/
|
||||||
toGNUCommandLineShell =
|
toGNUCommandLineShell =
|
||||||
options: attrs: lib.escapeShellArgs (toGNUCommandLine options attrs);
|
options: attrs: lib.escapeShellArgs (toGNUCommandLine options attrs);
|
||||||
|
|
Loading…
Reference in a new issue