9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'modules/wmflib/functions/argparse.pp', line 9
function wmflib::argparse (
Hash[String[2], Variant[Boolean, String, Numeric, Array[Variant[String, Numeric]]]] $args,
String $prefix = '',
String[1,1] $separator = ' ',
) >> String {
$args.reduce($prefix) |$memo, $value| {
$args_str = $value[1] ? {
Boolean => $value[1].bool2str(" --${value[0]}", ''),
Array => " --${value[0]}${separator}${value[1].join(',').shell_escape}",
# handle spaces, double quotes, etc.
default => " --${value[0]}${separator}${value[1].shell_escape}",
}
"${memo}${args_str}".strip
}
}
|