about summary refs log tree commit diff
path: root/lib/cli.nix
AgeCommit message (Collapse)AuthorFilesLines
2024-05-22cli.nix: permit separators between args -> `-a=b`, `--xyz=abc`, etcRob Pilling1-1/+10
2024-03-22doc: migrate lib.cli to use doc-commentsJohannes Kirschbauer1-37/+58
2020-01-23lib/cli: mkKey -> mkOptionName, use generators.mkValueStringDefaultProfpatsch1-11/+25
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-23lib/cli: rename `renderX` options to `mkX`Profpatsch1-17/+14
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-23lib/cli,lib/tests/misc: somewhat more standard formattingProfpatsch1-42/+36
2020-01-23lib/cli: encodeGNUCommandLine -> toGNUCommandLineShellProfpatsch1-2/+24
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-05Factor out a `toGNUCommandLine` utilityGabriel Gonzalez1-7/+11
... as suggested by @roberth
2019-12-15Use a more realistic example that exercises all encodingsGabriel Gonzalez1-3/+18
... as suggested by @roberth This also caught a bug in rendering lists, which this change also fixes
2019-12-13Make behavior of `encodeGNUCommandLine` customizableGabriel Gonzalez1-13/+17
... based on feedback from @edolstra
2019-12-13Rename `renderOptions` to `encodeGNUCommandLine`Gabriel Gonzalez1-2/+2
... as suggested by @edolstra
2019-12-11Add `pkgs.lib.renderOptions`Gabriel Gonzalez1-0/+33
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