Lumesh Built-in Function Documentation: Core Modules Modules
Module
Purpose
Representative Functions
fs
File system operations
read, write, ls, dirs
string
String operations
split, join, replace, lower, upper
regex
Regular expression operations
match, replace, search
list
List operations
first, last, map, filter
map
Map operations
keys, values, merge
math
Mathematical functions
sin, cos, sqrt, rand
rand
Random number operations
generation int, float, choice, shuffle
time
Date and time operations
now, parse, fmt, stamp
parse
Data conversion operations
json, toml, expr, cmd
into
Data conversion operations
int,string,time,table
os
Operating system related
name,family
sys
Environment variable operations
env, define, defined
console
Console operations
color, table, prompt
widget
UI widget operations
prompt, progress, table
ui
UI component
fzp, fzpi
log
Log operations
debug, info, warn, error
fmt
Format operations
red,pad,format,strip
Top-Level Functions 1. Environment Control Functions
cd
Function : Change the current working directory
Parameters :
path: String | Symbol
- Target path (supports ~
for home directory)
Returns : None
Example :
exit
Function : Terminate the process
Parameters :
[Optional] code: Integer
- Exit status code (default is 0)
Returns : None (directly terminates the process)
Example :
set same as sys.set
unset same as sys.unset
print
/ println
Function : Print parameters (println
automatically adds a newline)
Parameters :
...values: Any
- Any number of parameters
Returns : None
Example :
pprint
Function : Print parameters pretty
Parameters :
Returns : None
Example :
0...10 | pprint() fs.ls -l | pprint()
eprint
/ eprintln
Function : Output to the red error stream (with ANSI color codes)
Parameters :
...values: Any
- Any number of parameters
Returns : None
Example :
eprintln "Error: File not found"
tap
Function : Print parameter values and return them unchanged
Parameters :
...values: Any
- Any number of parameters
Returns : The last parameter or the parameter list
Example :
tap (range 5) |> map (*2)
read
Function : Read user input
Parameters :
[Optional] ...prompt: Any
- Any number of prompt messages
Returns : String
Example :
let name = read "Enter name:"
3. Type Operation Functions
type
Function : Get the type name of a value
Parameters :
value: Any
- Value of any type
Returns : String
Example :
to convert between data types, look into into
module.
4. Data Structure Functions
** get
**
insert
Function : Insert an element into a container
Parameters :
index: Integer | String
- Index (numbers for lists, strings for dictionaries)
value: Any
- Value to insert
container: List | HMap | Map | String
- Target container
Returns : New container
Example :
insert 0 "X" ["A" "B" ] insert "key" 42 {}
len
Function : Get the length of a container
Parameters :
container: List | HMap | Map | String | Bytes
Returns : Integer
Example :
rev
Function : Reverse a sequence
Parameters :
container: List | String | Symbol | Bytes
Returns : Reversed result of the same type
Example :
flatten
Function : Flatten a nested structure
Parameters :
container: List | HMap | Map
Returns : List
Example :
5. Advanced Operation Functions
where
Function : Filter table rows (third part cmd is to be used with parse.cmd
)
Parameters :
condition: Lambda/Function
- Boolean condition
rows: List
- List of row data (each row is a Map/HMap)
Returns : List
Example :
supported vars: LINENO
, LINES
and keys of the map.
fs.ls -l | where (size<1K) fs.ls -l | where (LINENO>1)
select
Function :Select table cols(third part cmd is to be used with parse.cmd
)
Parameters :
headers: 1 List/ many symbol
- headers list
rows: List
- List of row data(each row is a Map/HMap)
Returns :List
Example :
fs.ls -l | select (name,size)
repeat
Function : Generate values repeatedly
Parameters :
count: Integer
- Number of repetitions
generator: Expression
- Generation expression
Returns : List
Example :
6. Script Import and Execution Functions
import
Function : Import and execute a script file (creates a new environment)
Parameters :
path: String
- File path (based on the current working directory)
Returns : Result of the last expression in the file
Example :
include
Function : Import and execute a script file (shares the current environment)
Parameters :
Returns : Result of the last expression in the file
Note : The difference from import
is the environment sharing mechanism
Example :
eval
Function : Dynamically execute an expression (creates a new environment)
Parameters :
expression: Any
- Executable expression
Returns : Result of the expression execution
Example :
eval (parse.expr "(1 + 2) * 3" )
exec_str
Function : Dynamically execute a string expression (shares the current environment)
Parameters :
expression: String
- Executable expression
Returns : Result of the expression execution
Example :
exec
Function : Dynamically execute an expression (shares the current environment)
Parameters :
expression: Any
- Executable expression
Returns : Result of the expression execution
Example :
exec (parse.expr "(1 + 2) * 3" )
debug
Function : Print debugging information for parameters (with type identification)
Parameters :
...values: Any
- Any number of parameters
Returns : None
Example :
report
Function : Format and print complex data structures
Parameters :
value: HMap | Map | String
- Structured data
Returns : None
Example :
report {name: "Alice" , age: 30}
8. Help System Functions
help
Function : Display built-in function documentation
Parameters :
[Optional] name: String
- Module name/function name
Returns :
Returns a list of all functions when no parameters are provided
Returns documentation for the specified function when a parameter is provided
Example :
help about+-------------------------------------------------+ | KEY VALUE | +=================================================+ | version "0.4.4" | | git "https://codeberg.com/santo/lumesh" | | author "Adam McDaniel, santo" | | path "/tmp/target/debug/lume" | | suggestion "Use the `?:` to handle errors and | | read error messages!" || homepage "https://codeberg.com/santo/lumesh" | | prelude None | | license "APACHE-2.0" | +-------------------------------------------------+
Note: All built-in functions support two calling syntaxes:func(arg1, arg2)
or func arg1 arg2
It is recommended to use the first form when parameters contain complex structures.