lib/cli: add toCommandLine
This commit is contained in:
@@ -3106,6 +3106,86 @@ runTests {
|
||||
expected = "-X PUT --data '{\"id\":0}' --retry 3 --url https://example.com/foo --url https://example.com/bar --verbose";
|
||||
};
|
||||
|
||||
testToCommandLine = {
|
||||
expr =
|
||||
let
|
||||
optionFormat = optionName: {
|
||||
option = "-${optionName}";
|
||||
sep = "=";
|
||||
explicitBool = true;
|
||||
};
|
||||
in
|
||||
cli.toCommandLine optionFormat {
|
||||
v = true;
|
||||
verbose = [
|
||||
true
|
||||
true
|
||||
false
|
||||
null
|
||||
];
|
||||
i = ".bak";
|
||||
testsuite = [
|
||||
"unit"
|
||||
"integration"
|
||||
];
|
||||
e = [
|
||||
"s/a/b/"
|
||||
"s/b/c/"
|
||||
];
|
||||
n = false;
|
||||
data = builtins.toJSON { id = 0; };
|
||||
};
|
||||
|
||||
expected = [
|
||||
"-data={\"id\":0}"
|
||||
"-e=s/a/b/"
|
||||
"-e=s/b/c/"
|
||||
"-i=.bak"
|
||||
"-n=false"
|
||||
"-testsuite=unit"
|
||||
"-testsuite=integration"
|
||||
"-v=true"
|
||||
"-verbose=true"
|
||||
"-verbose=true"
|
||||
"-verbose=false"
|
||||
];
|
||||
};
|
||||
|
||||
testToCommandLineGNU = {
|
||||
expr = cli.toCommandLineGNU { } {
|
||||
v = true;
|
||||
verbose = [
|
||||
true
|
||||
true
|
||||
false
|
||||
null
|
||||
];
|
||||
i = ".bak";
|
||||
testsuite = [
|
||||
"unit"
|
||||
"integration"
|
||||
];
|
||||
e = [
|
||||
"s/a/b/"
|
||||
"s/b/c/"
|
||||
];
|
||||
n = false;
|
||||
data = builtins.toJSON { id = 0; };
|
||||
};
|
||||
|
||||
expected = [
|
||||
"--data={\"id\":0}"
|
||||
"-es/a/b/"
|
||||
"-es/b/c/"
|
||||
"-i.bak"
|
||||
"--testsuite=unit"
|
||||
"--testsuite=integration"
|
||||
"-v"
|
||||
"--verbose"
|
||||
"--verbose"
|
||||
];
|
||||
};
|
||||
|
||||
testSanitizeDerivationNameLeadingDots = testSanitizeDerivationName {
|
||||
name = "..foo";
|
||||
expected = "foo";
|
||||
|
||||
Reference in New Issue
Block a user