Skip to content

Commit 57551b9

Browse files
Add --pref option
This allows setting preferences through the commandline.
1 parent f502c9b commit 57551b9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

app/src/processing/app/Base.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,14 @@ public Base(String[] args) throws Exception {
364364
showError(null, "Argument required for --curdir", null);
365365
continue;
366366
}
367+
if (args[i].equals("--pref")) {
368+
i++;
369+
if (i < args.length)
370+
processPrefArgument(args[i]);
371+
else
372+
showError(null, "Argument required for --pref", null);
373+
continue;
374+
}
367375
if (args[i].startsWith("--"))
368376
showError(null, I18n.format(_("unknown option: {0}"), args[i]), null);
369377

@@ -496,6 +504,14 @@ protected void processBoardArgument(String selectBoard) {
496504
}
497505
}
498506

507+
protected void processPrefArgument(String arg) {
508+
String[] split = arg.split("=", 2);
509+
if (split.length != 2 || split[0].isEmpty())
510+
showError(null, I18n.format(_("{0}: Invalid argument to --pref, should be of the form \"pref=value\""), arg), null);
511+
512+
Preferences.set(split[0], split[1]);
513+
}
514+
499515
public Map<String, Map<String, Object>> getBoardsViaNetwork() {
500516
return new HashMap<String, Map<String, Object>>(boardsViaNetwork);
501517
}

0 commit comments

Comments
 (0)