utility
Namespace: global/api/utility
fn note
fn note(prompt: String, msg: String)
Displays a note to the user.
fn confirm
fn confirm(msg: String, initial_value: bool) -> bool
Displays a confirmation prompt to the user.
fn select
fn select(msg: String, initial_value: String, items: Array) -> String
Displays a single-choice selection menu.
fn multi_select
fn multi_select(msg: String, initial_values: Array, items: Array) -> Array
Displays a multi-choice selection menu.
fn resolve_home
fn resolve_home(path: String) -> String
Resolves `~` in a path to the user's home directory.
fn read_file
fn read_file(path: String) -> String
Reads the entire content of a file into a string.
fn write_file
fn write_file(path: String, content: String, append: bool)
Writes a string to a file, optionally appending to existing content.
fn regex_replace
fn regex_replace(input: String, pattern: String, replace: String) -> String
Replaces occurrences in a string using a Regular Expression.
fn create_tmp_dir
fn create_tmp_dir() -> TmpDir
Creates a temporary directory that is deleted when the handle is dropped.
fn get_tmp_path
fn get_tmp_path(tmp_dir: TmpDir) -> String
Returns the absolute path of a temporary directory handle.
fn remove_file
fn remove_file(path: String)
Removes a file from the filesystem.
fn copy_recursive
fn copy_recursive(src: String, dst: String)
Recursively copies a directory or file to a destination.
fn parse_json
fn parse_json(json: String) -> ?
Parses a JSON string into a Rhai Map or Array.
fn path_exists
fn path_exists(path: String) -> bool
Checks if a path exists on the filesystem.
fn ensure_dir
fn ensure_dir(path: String)
Ensures a directory exists, creating it and any parents if necessary.