Types And Functions - ConfigMate/configmate GitHub Wiki

ConfigMate Field Types

Primitive Types

Bool (bool)

Method Description Signature
eq Checks that the value is equal to the argument. bool.eq(arg bool) bool
toString Converts the value to a string. bool.toString() string

Int (int)

Method Description Signature
eq Checks that the value is equal to the argument. int.eq(arg int) bool
gt Checks that the value is greater than the argument. int.gt(arg int) bool
gte Checks that the value is greater than or equal to the argument. int.gte(arg int) bool
lt Checks that the value is less than the argument. int.lt(arg int) bool
lte Checks that the value is less than or equal to the argument. int.lte(arg int) bool
range Checks that the value is in the range [min, max]. int.range(min int, max int) bool
toFloat Converts the value to a float. int.toFloat() float
toString Converts the value to a string. int.toString() string

Float (float)

Method Description Signature
eq Checks that the value is equal to the argument. float.eq(arg float) bool
gt Checks that the value is greater than the argument. float.gt(arg float) bool
gte Checks that the value is greater than or equal to the argument. float.gte(arg float) bool
lt Checks that the value is less than the argument. float.lt(arg float) bool
lte Checks that the value is less than or equal to the argument. float.lte(arg float) bool
range Checks that the value is within the specified range. float.range(min float, max float) bool
toInt Converts the value to an int. float.toInt() int
toString Converts the value to a string. float.toString() string

String (string)

Method Description Signature
eq Checks that the value is equal to the specified string. string.eq(s string) bool
regex Checks that the value matches the specified pattern. string.regex(pattern string) bool

Composite Types

List (list<type>)

Method Description Signature
at Returns the element at the given index. list.at(index int) elementtype
len Returns the length of the list. list.len() int

Object (object)

The type object does not provide any methods and is therefore not used in checks; this type is only used to define the structure of the configuration file.

High Level Types

File (file)

Method Description Signature
exists Checks that the file exists. file.exists() bool
isDir Checks that the file is a directory. file.isDir() bool
parentExists Checks that the parent directory exists. file.parentExists() bool
size Gets the size of the file in bytes. file.size() int
perms Gets the permissions of the file as a string. file.perms() string
user Gets the user that owns the file. file.user() string
group Gets the group that owns the file. file.group() string
toString Converts the value to a string. file.toString() string

HostPort (host_port)

Method Description Signature
live Checks that the host:port is live. host_port.live() bool
getHost Gets the host. host_port.getHost() host
getPort Gets the port. host_port.getPort() port
toString Converts the value to a string. host_port.toString() string

Host (host)

Method Description Signature
reachable Checks that the host is reachable. host.reachable() bool
addPort Adds a port to the host to form a host_port type. host.addPort(p port) host_port
toString Converts the value to a string. host.toString() string

Port

Method Description Signature
open Checks that the port is open. port.open() bool
live Checks that the port is live. port.live() bool
toInt Converts the value to an int. port.toInt() int

Custom Object

CMSL allows us to create custom objects; these will only support a get method that receives the object field name as a string.

Method Description Signature
get Gets the specified field custom_object.get(field string) fieldtype
⚠️ **GitHub.com Fallback** ⚠️