file
content"""
key1=value1
[section1]
key2=value2
""".write_to_file("my_config.ini")
var ini = new IniFile.from_file("my_config.ini")
assert ini["key1"] == "value1"
assert ini["section1.key2"] == "value2"
"my_config.ini".to_path.delete
See also stop_on_first_error
and errors
.
# Create a IniFile from a `file` content
#
# ~~~
# """
# key1=value1
# [section1]
# key2=value2
# """.write_to_file("my_config.ini")
#
# var ini = new IniFile.from_file("my_config.ini")
# assert ini["key1"] == "value1"
# assert ini["section1.key2"] == "value2"
#
# "my_config.ini".to_path.delete
# ~~~
#
# See also `stop_on_first_error` and `errors`.
init from_file(file: String, stop_on_first_error: nullable Bool) do
init stop_on_first_error or else false
load_file(file)
end
lib/ini/ini.nit:101,2--121,4