Loading lib/cli.nix +10 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,16 @@ rec { mkOption ? k: v: if v == null then [] else [ (mkOptionName k) (lib.generators.mkValueStringDefault {} v) ] else if optionValueSeparator == null then [ (mkOptionName k) (lib.generators.mkValueStringDefault {} v) ] else [ "${mkOptionName k}${optionValueSeparator}${lib.generators.mkValueStringDefault {} v}" ], # how to separate an option from its flag; # by default, there is no separator, so option `-c` and value `5` # would become ["-c" "5"]. # This is useful if the command requires equals, for example, `-c=5`. optionValueSeparator ? null }: options: let Loading lib/tests/misc.nix +21 −0 Original line number Diff line number Diff line Loading @@ -1639,6 +1639,27 @@ runTests { ]; }; testToGNUCommandLineSeparator = { expr = cli.toGNUCommandLine { optionValueSeparator = "="; } { 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; }; expected = [ "-X=PUT" "--data={\"id\":0}" "--retry=3" "--url=https://example.com/foo" "--url=https://example.com/bar" "--verbose" ]; }; testToGNUCommandLineShell = { expr = cli.toGNUCommandLineShell {} { data = builtins.toJSON { id = 0; }; Loading Loading
lib/cli.nix +10 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,16 @@ rec { mkOption ? k: v: if v == null then [] else [ (mkOptionName k) (lib.generators.mkValueStringDefault {} v) ] else if optionValueSeparator == null then [ (mkOptionName k) (lib.generators.mkValueStringDefault {} v) ] else [ "${mkOptionName k}${optionValueSeparator}${lib.generators.mkValueStringDefault {} v}" ], # how to separate an option from its flag; # by default, there is no separator, so option `-c` and value `5` # would become ["-c" "5"]. # This is useful if the command requires equals, for example, `-c=5`. optionValueSeparator ? null }: options: let Loading
lib/tests/misc.nix +21 −0 Original line number Diff line number Diff line Loading @@ -1639,6 +1639,27 @@ runTests { ]; }; testToGNUCommandLineSeparator = { expr = cli.toGNUCommandLine { optionValueSeparator = "="; } { 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; }; expected = [ "-X=PUT" "--data={\"id\":0}" "--retry=3" "--url=https://example.com/foo" "--url=https://example.com/bar" "--verbose" ]; }; testToGNUCommandLineShell = { expr = cli.toGNUCommandLineShell {} { data = builtins.toJSON { id = 0; }; Loading