Hymn comes with a set of standard libraries for typical operations.
io.size(path) |
Returns a file's size in bytes. |
io.read(path) |
Reads a file's contents into a string. |
io.read-lines(path) |
Reads a file's contents into an array of strings, separated by lines. |
io.write(path, value) |
Writes a string into a file, truncating if it exists. |
io.append(path, value) |
Appends a string into a file. |
io.exists(path) |
Returns true or false if a file exists. |
io.stats(path) |
Returns a table of information for a file. |
io.input() |
Reads user input into a string. |
io.move(source, destination) |
Renames a source file path to a destination file path. Returns true or false whether the operation was a success. |
io.copy(source, destination) |
Copies the contents of a source file to a new destination file. Returns true if the operation was a success. |
io.remove(path) |
Removes a file. Returns true or false whether the operation was a success. |
stdout |
Convencience variable for use with print statements. Equal to 0. |
stderr |
Convencience variable for use with print statements. Equal to 1. |
system(string) |
Runs a system command and returns the resulting output text. |
os.clock() |
Returns a float of the system clock divided by CLOCKS_PER_SEC. |
os.env(string) |
Returns a system environment variable, or none. |
os.popen(string, string) |
Calls popen with file and mode. Returns a pointer. |
os.pclose(pointer) |
Closes a popen pointer. |
os.fopen(string, string) |
Calls fopen with path and mode. Returns a pointer. |
os.fclose(pointer) |
Closes a fopen pointer. |
os.fget(pointer) |
Calls fgetc until EOF is reached on a given pointer. Returns the resulting string. |
os.exec(string) |
Runs a system command and returns the resulting integer code. |
path.working() |
Returns the current working directory as a string. |
path.convert(path) |
Converts non-system path separator characters to the current system path separator. |
path.normalize(path) |
Normalizes a path, removing extraneous dots. |
path.parent(path) |
Returns the parent directory of a given path. |
path.cat(paths...) |
Concatenates multiple paths into a single path using the current system path character. |
path.absolute(path) |
Converts a relative path into an absolute path. |
path.list(path) |
Returns an array of files and directories for a given path. |
path.walk(path) |
Recursively descends into a path and returns an array of all files and directories. |
path.base(path) |
Returns the base file name of the path. |
path.extension(path) |
Returns the extension name of a file. |
path.symbol() |
Returns the current system path separator character as a string. |
pattern.get(string, pattern, start) |
Returns an array of strings or none. The first string is the whole matching substring. Additional strings are for any groups. |
pattern.find(string, pattern, start) |
Returns an array of integers or none if no match is found. The first two integers are the start and end positions of the matching string. Each additional two integers
are for groups.
|
pattern.match(string, pattern, start) |
Returns true or false whether the whole string matches the pattern. |
pattern.replace(string, pattern, replace) |
Replaces all instances of pattern in string with the replacement string, and returns the updated string. |
text.contains(string, contains) |
Returns true or false if string contains the given string. |
text.starts(string, starts) |
Returns true or false if string starts with the given string. |
text.ends(string, ends) |
Returns true or false if string ends with the given string. |
text.replace(string, find, replace) |
Replaces all instances of find in string with the replacement string, and returns the updated string. |
text.trim(string) |
Removes leading and trailing space characters from the string. |
text.left-strip(string) |
Removes leading space characters from the string. |
text.right-strip(string) |
Removes trailing space characters from the string. |
text.join(array, string) |
Converts an array to a string, with an optional string delimiter. |
text.split(string, string) |
Converts a string to an array, using a string delimiter. |