Added static convenience method for command-line escaping arguments (e.g. filebot/amc --def exec option)

e.g. quote(f) => "/path/to/file"
This commit is contained in:
Reinhard Pointner 2016-10-14 02:30:21 +08:00
parent 372bbcd5be
commit c402511f56
1 changed files with 6 additions and 0 deletions

View File

@ -54,6 +54,12 @@ public class ExpressionFormatFunctions {
return Stream.concat(Stream.of(c1, c2), Stream.of(cN)).map(ExpressionFormatFunctions::call).filter(Objects::nonNull);
}
public static String quote(Object c1, Object... cN) {
String q = String.valueOf('"');
String r = "\\" + q;
return stream(c1, null, cN).map(Objects::toString).map(s -> q + s.replace(q, r) + q).collect(joining(" "));
}
public static Map<String, String> csv(String path) throws IOException {
Pattern[] delimiter = { TAB, SEMICOLON };
Map<String, String> map = new LinkedHashMap<String, String>();