Settings Allows for Easy, documented settings files

Note: Usually prefer JsonUtils has it is a bit more flexible/sturdy than serialization.

All fields with the Facet "Setting" will be saved (using serialization: writeObj/ReadObj) Fields with the Setting Facet can NOT be nullable. Fields are stored using fantom serialization If there is a default value it will be displayed as well (as a comment in saved file) Note: It even works with "Complex" serialized obects, although it is less user friendly (better to stick to "simples")


Str commentChar := "#"

Line comment char (default: #)


Str[] headComments := Str[,]

Comments to show at the top of the file commentChar will be prepanded to each line


static Obj? load(File file, Type type, Bool createIfMissing := true)

Load settings from a file into given type


new make(|This f)


Obj? read(Type type, InStream in)

Load the settings from a stream/file and inject the into a new object of given type the type must have an it constructor ! new make(|This| f) {f(this)}


Void save(Obj o, OutStream out)

Save the settings (complete overwrite) Closes the stream when done


Str[] tailComments := Str[,]

Comments to show at the bottom of the file commentChar will be prepanded to each line


Void update(Obj o, File f)

Try to save the file "in place" Not touching existing comment lines If the file does not exist then it just calls save()