The Config API provides functions for managing configuration values.
Gets a config value by path, with support for dot notation.
Parameters:
- path
: The path to get the value from
- defaultValue
: The default value to return if the path doesn't exist
Example:
local theme = config.get("theme", "light")
print("Current theme: " .. theme)
Sets a config value by path, with support for dot notation.
Parameters:
- path
: The path to set the value at
- value
: The value to set
Example:
config.set("theme", "dark")
Sets multiple config values at once.
Parameters:
- values
: An object containing key-value pairs to set
Example:
config.set({
theme = "dark",
fontSize = 14
})
Checks if a config path exists.
Parameters:
- path
: The path to check
Example:
if config.has("theme") then
print("Theme is configured")
end
Defines a JSON schema for a configuration key. The schema will be used to validate values when setting this key.
Parameters:
- key
: The configuration key to define a schema for
- schema
: The JSON schema to validate against
Example:
config.define("theme", {
type = "string",
enum = {"light", "dark"}
})