-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpreferences.groovy
More file actions
49 lines (32 loc) · 872 Bytes
/
preferences.groovy
File metadata and controls
49 lines (32 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env filebot -script
def prefs = java.util.prefs.Preferences.userRoot()
def printPreferences = {
log.fine "Print $prefs"
def buffer = new ByteArrayOutputStream()
prefs.exportSubtree(buffer)
println buffer.toString('UTF-8')
}
def importPreferences = { f ->
log.fine "Import $prefs from $f"
prefs.importPreferences(f.newInputStream())
}
def exportPreferences = { f ->
log.fine "Export $prefs to $f"
prefs.exportSubtree(f.newOutputStream())
}
def clearPreferences = {
log.fine "Clear $prefs"
prefs.childrenNames().each{ prefs.node(it).removeNode() }
prefs.clear();
}
if (args) {
args.each{ f -> importPreferences(f) }
}
if (_args.output) {
def f = new File(_args.output, System.getProperty('user.name') + '.prefs.xml').getCanonicalFile()
exportPreferences(f)
}
if (_args.action == 'clear') {
clearPreferences()
}
printPreferences()