Commit Graph

10 Commits

Author SHA1 Message Date
Johannes Kirschbauer
6bcb2b90ed
doc: migrate lib.cli to use doc-comments 2024-03-22 09:54:17 +01:00
Profpatsch
7228a3c0bc lib/cli: mkKey -> mkOptionName, use generators.mkValueStringDefault
Let’s call them by what they are, option names.

`generators.mkValueStringDefault` is a better value string renderer
than plain `toString`.

Also add docs to all options.
2020-01-23 14:47:38 +01:00
Profpatsch
e71e1be859 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.
2020-01-23 14:47:38 +01:00
Profpatsch
b2654c226a lib/cli,lib/tests/misc: somewhat more standard formatting 2020-01-23 14:47:38 +01:00
Profpatsch
582354d3b6 lib/cli: encodeGNUCommandLine -> toGNUCommandLineShell
The semantic difference between `encode` and `to` is not apparent.
Users are likely to confuse both functions (which leads to unexpected
error messages about the wrong types). Like in `generators.nix`, all
functions should be prefixed by `to`.

Furthermore, converting to a string depends on the target context. In
this case, it’s a POSIX shell, so we should name it that (compare
`escapeShellArg` in `strings.nix`).

We can later add versions that escape for embedding in e.g. python
scripts or similar.
2020-01-23 14:47:38 +01:00
Gabriel Gonzalez
6d584c2614 Factor out a toGNUCommandLine utility
... as suggested by @roberth
2020-01-05 13:03:00 -08:00
Gabriel Gonzalez
5edd4dd44c Use a more realistic example that exercises all encodings
... as suggested by @roberth

This also caught a bug in rendering lists, which this change also fixes
2019-12-15 08:21:41 -08:00
Gabriel Gonzalez
693096d283 Make behavior of encodeGNUCommandLine customizable
... based on feedback from @edolstra
2019-12-13 18:25:52 -08:00
Gabriel Gonzalez
8c6a05c8c9 Rename renderOptions to encodeGNUCommandLine
... as suggested by @edolstra
2019-12-13 18:19:24 -08:00
Gabriel Gonzalez
183a99734f Add pkgs.lib.renderOptions
This adds a new utility to intelligently convert Nix records to
command line options to reduce boilerplate for simple use cases and to
also reduce the likelihood of malformed command lines
2019-12-11 16:30:05 -08:00