Rye Function Reference: Baseio ( Updated: "2026-11-02" )
Browse by source file and section. Examples are generated from builtin tests.
Printing
Interactive display and table printing helpers.
Printing
Interactive display and table printing helpers.
display
Displays all entries without interaction or pagination and returns the original value.
value Rye value to display without interaction or pagination
returns the original value
display 42 |type?
; prints "42
; "
display [1 2 3]
explore
Interactively explores a value; returns the selected item or the original value when cancelled.
value Block, Dict, Table, TableRow, Markdown, or Error to explore
returns the selected item or the original value when cancelled
[1 2 3] |explore
_..
Shorthand alias for explore: interactively select a value.
value Block, Dict, Table, TableRow, Markdown, or Error to explore interactively
returns the selected value or the original value when user exits
_.. [1 2 3]
explore\custom
Interactively displays a Table in the terminal with a custom rendering function for each row.
table Table to display
renderer Function called for each row with args (row is-current)
returns the selected row or original table when user exits
table { "n" } { 1 2 3 } |explore\custom fn { row is-curr } { if is-curr > 0 { print "*" } print row }
print\ssv
Prints a block of values as space-separated values followed by a newline, returning the input block.
values Block to format as space-separated values
returns the input block, unchanged
print\ssv { 1 2 "a" }
; prints "1 2 a
; "
print\csv
Prints a block of values as comma-separated values followed by a newline, returning the input block.
values Block to format as comma-separated values
returns the input block, unchanged
print\csv { 1 2 "a" }
; prints "1,2,a
; "
Base I/O
Saving state, loading scripts, process arguments, exit, and sandbox controls.
Runtime and Process Integration
Saving state, loading scripts, process arguments, exit, and sandbox controls.
scmd
Execute a shell command and return its exit status code.
cmd Shell command string to execute
returns integer exit status code
scmd "exit 0"
; returns 0
scmd "exit 3"
; returns 3
scmd 123
; correctly causes error:
; `scmd` expected String for argument 1
scmd\capture
Execute a shell command and capture the output, return it as string
cmd Shell command string to execute and capture output
returns string containing captured stdout (stderr on error)
scmd\capture "echo hi"
; returns "hi
; "
scmd\capture 123
; correctly causes error:
; `scmd\capture` expected String for argument 1
exit
Exits the process with the given integer status code (or 0 for any non-integer).
status Integer process exit status; non-integers exit with 0.
returns does not return; terminates the process.
; exit 0
Rye-itself//Args?
Returns command line arguments as a block of parsed values. Each argument is converted to appropriate type (integer, float, or string).
no arguments
returns block of values (each arg parsed as integer, float, or string)
Rye-itself//Args?
Rye-itself//Args\raw?
Returns raw command line arguments joined as a single string.
separator (ignored currently; kept for future parity) – pass _
returns string
Rye-itself//Args\\raw? _
Rye-itself//History?
Returns a block of the last N lines from REPL history.
rye-itself Native Rye-itself object passed via dot dispatch.
count Integer number of history lines to return.
returns Block of strings from REPL history; error when not running in the REPL.
Rye-itself//History? _ 10
Rye-itself//Landlock
Create a landlock builder object that can be configured and then enforced.
no arguments
returns native 'landlock' builder
ll: Rye-itself//Landlock
ll | landlock//Limit-to-cwd | landlock//Enforce
landlock//Limit-to-cwd
Limit landlock to current working directory (configure; does not enforce yet).
landlock native
returns same native (builder)
landlock//Allow
Allow access to a specific path (file or directory).
landlock native, path (uri|string)
returns same native (builder)
landlock//Allow-exec
Allow execute access to a specific file (or RX for all files under a directory).
landlock native, path (uri|string)
returns same native (builder)
landlock//Enforce
Enforce the configured landlock ruleset exactly once.
landlock native
returns same native (builder)
Rye-itself//Landlock-to-cwd
Restrict filesystem access to the current working directory and its subdirectories using Landlock (Linux only). Call early in the script.
no arguments
returns 'ok tagword on success; error on failure
Rye-itself//Landlock-only
Immediately restrict filesystem access to the provided list of paths with modes r, rw, or rx. Example: Rye-itself//Landlock-only "/proj:r,/tmp:rw,/proj/bin:rx"
spec (string or block of strings). Spec format examples
"/projr,/proj/bin
returns 'ok tagword on success; error on failure
Rye-itself//Is-unshare-fs
Returns true if filesystem namespace isolation is enabled under --unshare.
pureno arguments
returns boolean
Rye-itself//Is-unshare-net
Returns true if network namespace isolation is enabled under --unshare.
pureno arguments
returns boolean
Rye-itself//Is-unshare-pid
Returns true if PID namespace isolation is enabled under --unshare.
pureno arguments
returns boolean
Rye-itself//Is-unshare-uts
Returns true if UTS namespace isolation is enabled under --unshare.
pureno arguments
returns boolean
Rye-itself//Unshare-config?
Returns a dictionary with unshare isolation flags: active, fs, net, pid, uts (booleans).
pureno arguments
returns dict with keys: active, fs, net, pid, uts (booleans)
cc Rye-itself Unshare-config? |print
Rye-itself//Is-unshare
Returns true if current process runs inside Rye --unshare sandbox (Linux only).
pureno arguments
returns boolean, true when the runner set RYE_UNSHARE_CHILD=1
Rye-itself//Require-unshared
Fails and exits if unshare is not active (use in CI/safety-critical runs).
no arguments
returns never on failure (process exits); 'ok tagword when already unshared
Rye-itself//Is-dry-run
Returns true if Rye is running in dry-run/scenario mode (activated via --dry-run or scenario context)
pureno arguments
returns boolean, true when --dry-run is active or a scenario context is detected
capture-stdout
Executes a block of code while capturing all output to stdout, returning the captured output as a string.
block Block whose stdout should be captured.
returns String containing the captured stdout.
capture-stdout { print 1 }
; returns "1
; "
capture-stdout 1
; correctly causes error:
; `capture-stdout` expected Block for argument 1
IO
Console input and output functions
Console IO
Console input and output functions
input
Prompts for and reads user input from the console.
prompt string to display as a prompt
returns string containing the user's input
; File operations
file: Create %output.txt
file .Write "Hello, World!\n"
file .Close
Read %output.txt |print
; Reader/Writer operations
reader: Reader %data.txt
content: reader .Read\string
reader .Close
print content
; HTTP requests
Get https://api.example.com/data |print
Post https://api.example.com/data "{\"name\":\"test\"}" 'json |print
File Operations
File system operations and file manipulation
file-uri//Open
Opens a file for reading.
path uri representing the file to open
returns native file object
Open data/file.txt |type?
; returns native
Open data/file.txt |kind?
; returns file
file-uri//Open\append
Opens a file for appending.
path uri representing the file to open for appending
returns native writer object
Open\append data/file.txt |type?
; returns native
Open\append data/file.txt |kind?
; returns file
file-uri//Create
Creates a new file.
path uri representing the file to create
returns native file object
Create data/created.txt |type?
; returns native
Create data/created.txt |kind?
; returns file
file-uri//Ext?
Gets the extension of a file.
path uri or string representing a file path
returns string containing the file extension (including the dot)
Ext? data/file.txt
; returns ".txt"
Ext? data/file.temp.png
; returns ".png"
Ext? file "data/file.temp.png"
; returns ".png"
file-uri//Name?
Gets the filename with extension from a file path.
path uri representing a file path
returns string containing the filename with extension
Name? data/file.txt
; returns "file.txt"
file-uri//Stem?
Gets the filename without extension from a file path.
path uri representing a file path
returns string containing the filename without extension
Stem? data/file.txt
; returns "file"
file-uri//Dir?
Gets the directory path from a file path.
path uri representing a file path
returns string containing the directory path
Dir? data/file.txt
; returns "data"
file-uri//Split
Splits a file path into its components.
path uri representing a file path
returns block of strings containing path components
Split data/file.txt
; returns { "data" "file.txt" }
file-uri//Is-absolute
Checks if a file path is absolute.
path uri representing a file path
returns boolean indicating whether the path is absolute
Is-absolute /tmp
; returns true
Is-absolute data/file.txt
; returns false
file-uri//Does-exist
Checks if a file exists.
path uri representing a file path
returns boolean indicating whether the file exists
Does-exist data/file.txt
; returns true
Does-exist data/nonexistent.txt
; returns false
file-uri//Delete
Deletes a file.
path uri representing a file path to delete
returns true if the file was successfully deleted
file//Reader
Creates a new reader from file object.
source file object to read from
returns native reader object
Reader Open data/file.txt |kind?
; returns reader
file//Writer
Creates a new writer from a file object.
source file object to write to
returns native writer object
Writer Open data/file.txt |kind?
; returns writer
file-uri//Reader
Creates a new reader from a file uri/path.
source file uri to read from
returns native reader object
Reader data/file.txt |kind?
; returns reader
reader
Creates a new reader from a string.
source string to read from
returns native reader object
reader "some string" |kind?
; returns reader
stdin
Gets a reader for standard input.
no arguments
returns native reader object connected to standard input
stdout
Gets a writer for standard output.
no arguments
returns native writer object connected to standard output
stderr
Gets a writer for standard error.
no arguments
returns native writer object connected to standard error
reader//Read\string
Reads all content from a reader as a string.
reader native reader object
returns string containing all content from the reader
reader "some string" |Read\string
; returns "some string"
reader//Close
Closes a reader if it implements io.Closer.
reader native reader object
returns empty string if successful
Reader data/file.txt |Close |type?
; returns string
reader//Copy
Copies all content from a reader to a writer.
reader native reader object
writer native writer object
returns the reader object if successful
file//Copy
Copies content from a file to a writer.
file native file object
writer native writer object
returns the file object if successful
file//Stat
Gets file information (stat) for a file.
file native file object
returns native file-info object
Stat Open data/file.txt |kind?
; returns file-info
file-info//Size?
Gets the size of a file in bytes.
file-info native file-info object
returns integer representing the file size in bytes
Size? Stat Open data/file.txt
; returns 16
file//Read
Reads the entire content of a file as a string.
file native file object
returns string containing the entire file content
Read Open data/file.txt
; returns "hello text file
; "
file//Seek\end
Seeks to the end of a file.
file native file object
returns the same file object with position set to end of file
file//Write
Writes a string directly to a file object.
file native file object
content string to write to the file
returns the file object if successful (allows chaining)
file//Close
Closes an open file.
file native file object
returns empty string if successful
Close Open data/file.txt
; returns ""
file-uri//Read
Reads the entire content of a file as a string.
path uri representing the file to read
returns string containing the entire file content
Read data/file.txt
; returns "hello text file
; "
file-uri//Read\bytes
Reads the entire content of a file as bytes.
path uri representing the file to read
returns native bytes object containing the file content
Read data/file.txt
; returns "hello text file
; "
file-uri//Read\lines
Reads a file and returns its content as a block of lines.
path uri representing the file to read
returns block of strings, each representing a line from the file
Read data/file.txt
; returns "hello text file
; "
file-uri//Write
Writes content to a file.
path uri representing the file to write to
content string or bytes to write to the file
returns the content that was written
Write data/write.txt "written
"
; returns "written
; "
write\bytes
Writes bytes to a file.
bytes Go-bytes native value to write
path string path to the file to write
returns integer 1 if successful
append\bytes
Appends two byte arrays into one.
bytes1 first Go-bytes native value
bytes2 second Go-bytes native value
returns combined bytes as a native bytes object
writer//Write
Writes a string to a writer.
writer native writer object
content string to write
returns the writer object if successful
HTTPs Operations
Web requests and HTTP protocol functions
https-uri//Ext?
Gets the extension of the last path component of an HTTPS URL.
url uri representing the HTTPS URL
returns string containing the extension of the last path component
Ext? uri "https://example.com/data/file.txt"
; returns ".txt"
https-uri//Name?
Gets the last path component (filename) from an HTTPS URL.
url uri representing the HTTPS URL
returns string containing the last path component with extension
Name? uri "https://example.com/data/file.txt"
; returns "file.txt"
https-uri//Stem?
Gets the last path component (filename) without its extension from an HTTPS URL.
url uri representing the HTTPS URL
returns string containing the last path component without extension
Stem? uri "https://example.com/data/file.txt"
; returns "file"
https-uri//Dir?
Gets the directory portion of an HTTPS URL path (including the host).
url uri representing the HTTPS URL
returns string containing the directory portion of the URL path (including host)
Dir? uri "https://example.com/data/file.txt"
; returns "example.com/data"
https-uri//Open
Opens a HTTPS GET request and returns a reader for the response body.
url uri representing the HTTPS URL to request
returns native reader object for the response body
https-uri//Get
Makes a HTTPS GET request and returns the response body as a string.
url uri representing the HTTPS URL to request
returns string containing the response body
https-uri//Post
Makes a HTTPS POST request and returns the response body as a string.
url uri representing the HTTPS URL to request
data string containing the request body
content-type word specifying the content type (e.g., 'json', 'text')
returns string containing the response body
http-uri//Ext?
Gets the extension of the last path component of an HTTP URL.
url uri representing the HTTP URL
returns string containing the extension of the last path component
Ext? uri "http://example.com/data/file.txt"
; returns ".txt"
http-uri//Name?
Gets the last path component (filename) from an HTTP URL.
url uri representing the HTTP URL
returns string containing the last path component with extension
Name? uri "http://example.com/data/file.txt"
; returns "file.txt"
http-uri//Stem?
Gets the last path component (filename) without its extension from an HTTP URL.
url uri representing the HTTP URL
returns string containing the last path component without extension
Stem? uri "http://example.com/data/file.txt"
; returns "file"
http-uri//Dir?
Gets the directory portion of an HTTP URL path (including the host).
url uri representing the HTTP URL
returns string containing the directory portion of the URL path (including host)
Dir? uri "http://example.com/data/file.txt"
; returns "example.com/data"
http-uri//Open
Opens a HTTP GET request and returns a reader for the response body.
url uri representing the HTTP URL to request
returns native reader object for the response body
http-uri//Get
Makes a HTTP GET request and returns the response body as a string.
url uri representing the HTTP URL to request
returns string containing the response body
http-uri//Post
Makes a HTTP POST request and returns the response body as a string.
url uri representing the HTTP URL to request
data string containing the request body
content-type word specifying the content type (e.g., 'json', 'text')
returns string containing the response body
http-uri//Request
Creates a new HTTP request object.
url uri representing the HTTP URL to request
method word specifying the HTTP method (e.g., 'GET', 'POST', 'PUT', 'DELETE')
data string containing the request body
returns native http-request object
https-uri//Request
Creates a new HTTPS request object.
url uri representing the HTTPS URL to request
method word specifying the HTTP method (e.g., 'GET', 'POST', 'PUT', 'DELETE')
data string containing the request body
returns native https-request object
https-request//Header!
Sets a header on a HTTPS request.
request native https-request object
name word representing the header name
value string containing the header value
returns the request object if successful
https-request//Basic-auth!
Sets Basic Authentication on a HTTPS request.
request native https-request object
username string containing the username
password string containing the password
returns the request object if successful
https-request//Call
Executes a HTTPS request and returns the response object. Always returns the response regardless of status code (200, 404, 500, etc.) - use Status? to check the code.
request native https-request object
returns native https-response object (always returns response regardless of status code)
http-request//Header!
Sets a header on a HTTP request.
request native http-request object
name word representing the header name
value string containing the header value
returns the request object if successful
http-request//Basic-auth!
Sets Basic Authentication on a HTTP request.
request native http-request object
username string containing the username
password string containing the password
returns the request object if successful
http-request//Call
Executes a HTTP request and returns the response object. Always returns the response regardless of status code (200, 404, 500, etc.) - use Status? to check the code.
request native http-request object
returns native http-response object (always returns response regardless of status code)
https-response//Reader
Gets a reader for the HTTPS response body that can be used with io.Copy.
response native https-response object
returns native reader object for the response body
https-response//Read-body
Reads the body of a HTTPS response as a string.
response native https-response object
returns string containing the response body
http-response//Reader
Gets a reader for the HTTP response body that can be used with io.Copy.
response native http-response object
returns native reader object for the response body
http-response//Read-body
Reads the body of a HTTP response as a string.
response native http-response object
returns string containing the response body
https-response//Close-body!
Closes the HTTPS response body to free network resources.
response native https-response object
returns empty string if close succeeds
Email Operations
Email sending and SMTP communication
email//Send
Sends an email to the specified address.
to email address to send to
message string containing the email message
returns integer 1 if successful
FTP Operations
File Transfer Protocol operations and connections
ftp-uri//Open
Opens a connection to an FTP server.
server uri representing the FTP server to connect to
returns native ftp-connection object
ftp-connection//Login
Logs in to an FTP server connection.
connection native ftp-connection object
username string containing the username
password string containing the password
returns the connection object if successful
ftp-connection//Retrieve
Retrieves a file from an FTP server.
connection native ftp-connection object
path string containing the path of the file to retrieve
returns native reader object for the retrieved file
ftp-connection//Close
Closes an FTP server connection.
connection native ftp-connection object
returns integer 1 for success; error if close fails
equal { ftp: Open ftp://localhost:21 ftp .Close |type? } 'integer
ftp-connection//List
Lists directory entries. Returns a block of maps with full info.
connection native FTP connection.
path String directory path to list.
returns Block of dicts describing each directory entry.
; Requires ftp server on localhost:21 with anonymous or test creds
; Example smoke tests (skip in CI if no server):
; conn: ftp-uri: Open ftp://localhost:21
; conn: conn .Login "anonymous" "anonymous" ; or real creds
; conn .Cwd "/" |kind? |equal 'native
; conn .Mkdir "rye-test" |kind? |equal 'native
; conn .List "/" |type? |equal 'block
; conn .Store "/rye-test/hello.txt" "hi" |kind? |equal 'native
; r: conn .Retrieve "/rye-test/hello.txt" |kind? |equal 'reader
; r .Close |drop
; lst: conn .List "/rye-test"
; lst |length |>= 1 |assert
; conn .Rename "/rye-test/hello.txt" "/rye-test/hello2.txt" |kind? |equal 'native
; conn .Delete "/rye-test/hello2.txt" |kind? |equal 'native
; conn .Rmdir "/rye-test" |kind? |equal 'native
; conn .Close |equal 1
Additional FTP operations
ftp-connection//Cwd
Changes working directory.
connection native FTP connection.
path String directory to change to.
returns the FTP connection.
; conn .Cwd "/" |kind? |equal 'native
ftp-connection//Mkdir
Creates a directory.
connection native FTP connection.
path String directory to create.
returns the FTP connection.
; conn .Mkdir "rye-test" |kind? |equal 'native
ftp-connection//Rmdir
Removes a directory.
connection native FTP connection.
path String directory to remove.
returns the FTP connection.
; conn .Rmdir "rye-test" |kind? |equal 'native
ftp-connection//Delete
Deletes a file.
connection native FTP connection.
path String file to delete.
returns the FTP connection.
; conn .Delete "/rye-test/hello.txt" |kind? |equal 'native
ftp-connection//Rename
Renames or moves a file.
connection native FTP connection.
from String current path.
to String new path.
returns the FTP connection.
; conn .Rename "/rye-test/a.txt" "/rye-test/b.txt" |kind? |equal 'native
ftp-connection//Store
Uploads data to a remote path. Accepts string or reader.
connection native FTP connection.
path String remote destination path.
reader Reader supplying the file contents.
returns the FTP connection.
; conn .Store "/rye-test/up.txt" "content" |kind? |equal 'native
File Monitoring
File watching and tailing operations
tail-file
Tails a file, following it for new content. Used for monitoring log files.
path uri or string representing the file to tail
follow boolean indicating whether to follow the file for new content
reopen boolean indicating whether to reopen the file if it's rotated
returns native tail-file object that can be used to read lines as they are added
tail-file//Read-line
Reads the next line from a tailed file. Blocks until a line is available.
tail native tail-file object
returns string containing the next line from the file, or nil if no more lines
tail-file//Close
Closes a tailed file, stopping the monitoring.
tail native tail-file object
returns empty string if successful
Unix Domain Socket Operations
Unix domain socket operations for IPC
unix-uri//Open
Opens a connection to a Unix domain socket.
path uri representing the Unix socket path to connect to
returns native unix-connection object
unix-connection//Write
Writes data to a Unix domain socket connection.
connection native unix-connection object
data string to write to the socket
returns the connection object if successful (allows chaining)
unix-connection//Read
Reads data from a Unix domain socket connection.
connection native unix-connection object
returns string containing data read from the socket
unix-connection//Close
Closes a Unix domain socket connection.
connection native unix-connection object
returns empty string if successful
Table Files
Load and save tables as CSV, TSV or XLSX files.
Table files
Load and save tables as CSV, TSV or XLSX files.
file-uri//Load\csv__OLD
Loads a .csv file to a table datatype.
file-uri - location of csv file to load
returns Table parsed from the CSV file.
type? Load\csv__OLD data/file.txt
; returns table
equal {
cc os
f:: mktemp ++ "/test.csv"
spr1:: table { "a" "b" "c" } { 1 1.1 "a" 2 2.2 "b" 3 3.3 "c" }
f .Save\csv spr1
spr2:: Load\csv f |autotype 1.0
spr1 = spr2
} true
file-uri//Load\csv
Loads a .csv file to a table datatype.
file-uri - location of csv file to load
separator - single character used as the column separator
returns Table parsed from the CSV file.
type? Load\csv data/file.txt ","
; returns table
equal {
cc os
f:: mktemp ++ "/test.csv"
spr1:: table { "a" "b" "c" } { 1 1.1 "a" 2 2.2 "b" 3 3.3 "c" }
f .Save\csv spr1
spr2:: Load\csv f "," |autotype 1.0
spr1 = spr2
} true
file-uri//Load\csv\ignore-bad
Loads a .csv file to a table datatype, parsing it line by line and skipping lines that can't be parsed as CSV.
file-uri - location of csv file to load
separator - single character used as column separator
returns Table parsed from the CSV file, skipping malformed lines.
equal {
cc os
f:: mktemp ++ "/test.csv"
f .Write "a;b;c\n1;1.1;a\nbad\"line\n2;2.2;b\n3;3.3;c\n"
spr:: Load\csv\ignore-bad f ";"
spr .length? 3
} true
file-uri//Load\tsv
Loads a .tsv file to a table datatype.
file-uri - location of tsv file to load
returns Table parsed from the TSV file.
type? Load\tsv data/file.txt
; returns table
equal {
cc os
f:: mktemp ++ "/test.tsv"
spr1:: table { "a" "b" "c" } { 1 1.1 "a" 2 2.2 "b" 3 3.3 "c" }
f .Save\tsv spr1
spr2:: Load\tsv f |autotype 1.0
spr1 = spr2
} true
file-uri//Save\csv
Saves a table to a .csv file.
file-uri - where to save the sheet as a .csv file
table - the table to save
returns the saved Table.
type? Save\csv ( os/mktemp ++ "/save.csv" ) table { "a" "b" } { 1 "x" }
; returns table
equal {
cc os
f:: mktemp ++ "/test.csv"
spr1:: table { "a" "b" "c" } { 1 1.1 "a" 2 2.2 "b" 3 3.3 "c" }
f .Save\csv spr1
spr2:: Load\csv f "," |autotype 1.0
spr1 = spr2
} true
file-uri//Save\tsv
Saves a table to a .tsv file.
file-uri - where to save the sheet as a .tsv file
table - the table to save
returns the saved Table.
type? Save\tsv ( os/mktemp ++ "/save.tsv" ) table { "a" "b" } { 1 "x" }
; returns table
equal {
cc os
f:: mktemp ++ "/test.tsv"
spr1:: table { "a" "b" "c" } { 1 1.1 "a" 2 2.2 "b" 3 3.3 "c" }
f .Save\tsv spr1
spr2:: Load\tsv f |autotype 1.0
spr1 = spr2
} true
file-uri//Load\xlsx
Loads the first sheet in an .xlsx file to a Table. Cells starting with "{" are loaded as Rye code.
file-uri - location of xlsx file to load
returns Table containing the first sheet of the XLSX file.
type? Save\xlsx ( os/mktemp ++ "/test.xlsx" ) table { "a" "b" } { 1 "x" 2 "y" }
; returns table
equal {
cc os
f:: mktemp ++ "/test.xlsx"
spr1:: table { "a" "b" "c" } { 1 1.1 "a" 2 2.2 "b" 3 3.3 "c" }
f .Save\xlsx spr1
spr2:: Load\xlsx f |autotype 1.0
spr1 = spr2
} true
file-uri//Save\xlsx
Saves a Table to a .xlsx file. Block cells are serialized with their Rye dump.
file-uri - where to save the table as a .xlsx file
table - the table to save
returns the saved Table.
type? Save\xlsx ( os/mktemp ++ "/save.xlsx" ) table { "a" "b" } { 1 "x" }
; returns table
f:: ( os/mktemp ++ "/block.xlsx" ) Save\xlsx f table { "a" } { { 12 123 123 "asds" } } Load\xlsx f |first |-> "a"
; returns { 12 123 123 "asds" }
equal {
cc os
f:: mktemp ++ "/test.xlsx"
spr1:: table { "a" "b" "c" } { 1 1.1 "a" 2 2.2 "b" 3 3.3 "c" }
f .Save\xlsx spr1
spr2:: Load\xlsx f |autotype 1.0
spr1 = spr2
} true
Cmd
Running other programs
Command Operations
Running other programs
cmd
Create a command.
command block or list containing a command arguments
returns native command object
cmd { echo -n Hello World } |Output
; returns "Hello World"
cmd { echo -n Hello World |tr A-Z a-z |sed "s/hello/goodbye/" } |Output
; returns "goodbye world"
cmd { echo -n "1 + 1 =" { 1 + 1 } } |Output
; returns "1 + 1 = 2"
args: list { "two" "arguments" } cmd { printf "'%s' " ?args } |Output
; returns "'two' 'arguments' "
command//Dir!
Change the working directory of a command.
command native command object
dir path to the working directory
returns the original command object
cmd { pwd } |Dir! / |Output |trim
; returns "/"
command//Stdin!
Change the standard input of a command.
command native command object
input path to an input file, a native file object, or a reader
returns the original command object
command//Stdout!
Change the standard output of a command.
command native command object
output path to an output file, a native file object, or a writer
returns the original command object
command//Stderr!
Change the standard error of a command.
command native command object
output path to an output file, a native file object, or a writer
returns the original command object
command//Pipe
Pipe the output of the first command to the input of the second command.
c1 first command writing to the pipe
c2 second command reading from the pipe
returns new native command object
cmd { echo -n Hello World } |Pipe cmd { tr a-z A-Z } |Output
; returns "HELLO WORLD"
command//Run
Start a command and wait for it to finish.
command native command object
returns boolean true if the command executed successfully
cmd { false } |Run
; correctly causes error:
; `Run`: exit status 1
command//Start
Start a command (and any piped commands) without waiting.
command native command object
returns the same command after starting it (does not wait)
command//Kill
Kill a started command (and any started piped commands).
command native command object
returns boolean true; kills the process (and any started piped processes)
command//Pid
Return the process id of the main command (or -1 if not started).
command native command object
returns process id of the main command or -1 if not started
command//Wait
Wait for a started command to finish and return its exit status.
command native command object
returns exit status (or list for pipelines) after waiting
command//Status
Start a command, wait for it to finish, and return its exit status.
command native command object
returns for simple command: exit status integer; for pipeline: list of exit status integers
cmd { true } |Status
; returns 0
cmd { false } |Status
; returns 1
cmd { false |true } |Status
; returns list { 1 0 }
command//Output
Start a command, wait for it to finish, and return its standard output
command native command object
returns string containing data written to the command's standard output
command//CombinedOutput
Start a command, wait for it to finish, and return its combined standard output and error
command native command object
returns string containing data written to the command's standard output and error
command//Detach!
Redirect stdin, stdout, and stderr of a command to /dev/null.
command native command object
returns the original command object after redirecting stdin/stdout/stderr to /dev/null
OS
OS related functions
OS
OS related functions
cwd?
Gets the current working directory.
no arguments
returns uri representing the current working directory
cc os
print cwd?
ls |for { .print }
ls\ 'files |for { .print }
host-info? -> "hostname" |print
load-avg? -> "1" |print
virtual-memory? -> "total" |print
disk-usage? |print
processes? |first |print
cc os cwd?
does-exist
Checks if a file or directory exists.
path uri representing the file or directory to check
returns boolean: true if exists, false if not
cc os does-exist main.rye
; returns true
cc os does-exist %./tests/data/file.txt
cd
Changes the current working directory.
path uri representing the directory to change to
returns the same uri if successful
cc os cd %.
env?
Gets the value of an environment variable.
variable_name string containing the name of the environment variable
returns string containing the value of the environment variable
cc os env? "PATH"
mkdir
Creates a new directory.
path uri representing the directory to create
returns the same uri if successful
cc os mkdir %./tests/delme
mktmp
Removed: use mktemp instead.
no arguments
returns uri representing the created temporary directory
; mktmp was removed; use mktemp instead.
cc os mktemp
rm
Removes a file or empty directory.
path uri representing the file or empty directory to remove
returns the uri if successful
cc os rm %./tests/delme
rmdir
Removes a directory and all its contents recursively.
path uri representing the directory to remove (including contents)
returns the uri if successful
cc os rmdir %./tests/delme
cp
Copies a file to a new location.
source uri representing the source file
destination uri representing the destination file
returns destination uri if successful
file-info?
Gets detailed information about a file or directory.
path uri representing the file or directory
returns dict with keys: name, size, mode, mod-time, is-dir
os/file-info? data/file.txt |type?
; returns dict
cc os file-info? %./tests/data/file.txt
is-dir
Checks if a path is a directory. Fails if the path does not exist.
path uri representing the path to check
returns boolean: true if path is a directory, false otherwise. Fails if the path does not exist.
os/is-dir data
; returns true
os/is-dir data/file.txt
; returns false
cc os is-dir %./tests/data
is-file
Checks if a path is a regular file (not a directory). Fails if the path does not exist.
path uri representing the path to check
returns boolean: true if path is a regular file, false otherwise. Fails if the path does not exist.
os/is-file data/file.txt
; returns true
os/is-file data
; returns false
cc os is-file %./tests/data/file.txt
home-dir?
Gets the current user's home directory.
no arguments
returns uri representing the user's home directory
cc os home-dir?
tmp-dir?
Gets the system's default temporary directory.
no arguments
returns uri representing the system's temporary directory
cc os tmp-dir?
glob
Returns files matching a glob pattern.
pattern string containing a glob pattern (e.g., "*.txt", "data/*.csv")
returns block of uris matching the pattern
cc os glob "./tests/data/*.pem"
mv
Moves or renames a file or directory.
source uri representing the source file or directory
destination uri representing the destination file or directory
returns destination uri if successful
ls
Lists files and directories in the current directory.
no arguments
returns block of uris representing files and directories in the current directory
cc os ls
ls\
Lists files or directories with absolute paths when possible. If argument is a file-uri, lists that directory (or returns failure if not a directory). Otherwise filters current directory: 'dirs' for directories only, 'files' for files only, a string for partial name matching, or a regex to match names.
filter file-uri to list directory, word 'dirs' or 'files' to filter by type, string for partial name matching, or regex to match names
returns block of uris representing filtered files or directories in the specified directory or current directory
cc os ls\ 'files
ls\dirs
Lists only directories in the current directory.
no arguments
returns block of uris representing directories in the current directory
cc os ls\\dirs
ls\files
Lists only files (non-directories) in the current directory.
no arguments
returns block of uris representing files (non-directories) in the current directory
cc os ls\\files
ls\dirs\
Lists directories in the current directory with filtering. Use a string for partial name matching, or a regex to match names.
filter string for partial name matching, or regex to match names
returns block of uris representing filtered directories in the current directory
cc os ls\\dirs\\ "src"
ls\files\
Lists files (non-directories) in the current directory with filtering. Use a string for partial name matching, or a regex to match names.
filter string for partial name matching, or regex to match names
returns block of uris representing filtered files (non-directories) in the current directory
cc os ls\\files\\ re "\.go$"
symlink
Creates a symbolic link.
path uri representing source path
link uri representing link path to create
returns link uri if successful
is-symlink
Checks if a path is a symbolic link. Fails if the path does not exist.
path uri representing a path to check
returns boolean: true if path is a symbolic link
readlink
Reads the target of a symbolic link.
path uri representing a symbolic link
returns uri representing the target of the symlink
chmod
Changes file or directory permissions.
path uri representing file or directory path
mode integer representing file mode (e.g., 0755)
returns path uri if successful
abs-path
Removed: use realpath instead.
path uri representing file or directory
returns string representing the absolute path
dirname
Returns the directory part of a path.
path uri representing a path
returns uri representing the directory containing the path
os/dirname data/file.txt |Name?
; returns "data"
cc os dirname %./tests/data/file.txt
basename
Returns the filename part of a path.
path uri representing a path
returns string representing the filename part of the path
os/basename data/file.txt
; returns "file.txt"
cc os basename %./tests/data/file.txt
file-ext
Returns the file extension of a path (including the dot).
path uri representing a file path
returns string representing the file extension (including the dot)
os/file-ext data/file.txt
; returns ".txt"
cc os file-ext %./tests/data/file.txt
join-path
Joins path elements into a single path.
paths uri or block of uris to join
returns uri representing the joined path
os/join-path { data "file.txt" } |Name?
; returns "file.txt"
cc os join-path { %./tests "data" "file.txt" }
whoami
Returns the current user's username.
no arguments
returns string representing the current user's username
cc os whoami
which
Finds the path to an executable command.
command string representing the command to check
returns uri representing the path to the executable, or error if not found
cc os which "sh"
pwd
Gets the current working directory (alias of cwd?).
no arguments
returns uri representing the current working directory
realpath
Returns the absolute path for a given path. Replaces the removed abs-path builtin.
path uri representing the path to resolve
returns uri representing the absolute path
mktemp
Creates a new temporary directory. Replaces the removed mktmp builtin.
no arguments
returns uri representing the created temporary directory
setenv!
Sets an environment variable (value, name).
value string value to assign
name string environment variable name
returns the value string
os/setenv! "ok" "RYE_TEST_DOC_ENV"
; returns "ok"
unsetenv!
Unsets an environment variable by name.
name string environment variable name
returns void
os/unsetenv! "RYE_TEST_DOC_ENV" |type?
; returns void
cp-r
Recursively copies a directory and all its contents.
source uri representing source directory
destination uri representing destination directory
returns destination uri if successful
mkdir-p
Creates a directory and any necessary parent directories.
path uri representing directory path to create
returns path uri if successful
host-info?
Gets information about the host system.
no arguments
returns dictionary containing information about the host system (hostname, uptime, OS, etc.)
users?
Gets information about users currently logged into the system.
no arguments
returns table containing information about users (user, terminal, host, started)
load-avg?
Gets the system load average over the last 1, 5, and 15 minutes.
no arguments
returns dictionary with keys "1", "5", and "15" representing load averages
virtual-memory?
Gets information about virtual memory usage.
no arguments
returns dictionary containing information about virtual memory (total, free, used-percent)
disk-usage?
Gets disk usage information for all partitions.
no arguments
returns table containing disk usage information for all partitions
pids?
Gets a list of all process IDs currently running.
no arguments
returns block of integers representing process IDs
processes\table?
Gets detailed information about all running processes.
no arguments
returns table containing detailed information about all running processes
process
Gets a native process object by PID (same as process?).
pid integer process ID
returns dictionary containing detailed information about the specified process
lookup-address
Performs a reverse DNS lookup to get hostnames for an IP address.
ip string containing an IP address
returns block of strings containing hostnames associated with the IP
lookup-ip
Performs a DNS lookup to get IP addresses for a hostname.
hostname string containing a hostname
returns block of strings containing IP addresses associated with the hostname
write\clipboard
Writes a string value to the system clipboard.
value string to write to the clipboard
returns the same string if successful
read\clipboard
Reads the current contents of the system clipboard.
no arguments
returns string containing the current contents of the clipboard
Archive Functions
Functions for creating and extracting archives
tgz
Creates a .tar.gz archive from a file or directory.
source uri representing the file or directory to archive
destination uri representing the output .tar.gz file
returns destination uri if successful
un-tgz
Removed: use untgz instead.
source uri representing the .tar.gz file
destination uri representing the output directory
returns never returns successfully; raises an error directing callers to untgz
zip
Creates a .zip archive from a file or directory, or from a block of files/directories.
source uri representing the file or directory to archive, or a block of uris/strings to archive together
destination uri representing the output .zip file
returns destination uri if successful
unzip
Extracts a .zip archive to a directory.
source uri representing the .zip file
destination uri representing the output directory
returns destination uri if successful
unzip\single
Opens the single file in a .zip archive and returns a reader for it. Fails if the archive contains more than one file.
source uri representing the .zip file, or a reader/http-response native containing .zip data
returns native reader object for the archive's only file (fails if there is more than one)
Find
File finding functions using go-find library
finder
Creates a new file finder starting from the given path(s).
path uri or block of uris/strings representing starting paths
returns native finder object
finder %src |Name "*.go" |Type 'file |Eval
finder %. |Max-depth! 2 |Name "*.txt" |Eval
finder %/home |Min-depth! 1 |Max-depth! 3 |Regex regex "test.*\.go$" |Eval
Creates a new finder starting from the given path(s).
finder//Min-depth!
Sets the minimum depth for file traversal.
finder native finder object
depth integer minimum depth
returns native finder object (for chaining)
finder//Max-depth!
Sets the maximum depth for file traversal.
finder native finder object
depth integer maximum depth
returns native finder object (for chaining)
finder//Type
Filters results by type: 'file (or "f") for files, 'dir (or "d") for directories.
finder native finder object
type word 'file or 'dir (or string "f" or "d")
returns native finder object (for chaining)
finder//Name
Filters results by file name using a glob pattern.
finder native finder object
pattern string glob pattern (e.g., "*.go", "test_*")
returns native finder object (for chaining)
finder//Whole-name
Filters results by full path using a glob pattern.
finder native finder object
pattern string glob pattern for the whole path
returns native finder object (for chaining)
finder//Regex
Filters results by regular expression on the full path.
finder native finder object
regex native regex object
returns native finder object (for chaining)
finder//Empty
Filters for empty files or directories.
finder native finder object
returns native finder object (for chaining)
finder//Mtime-since!
Filters for files modified within the last N milliseconds (e.g. 2 .days), truncated to whole seconds.
finder native finder object
millis integer number of milliseconds (Rye durations such as 2 .days are in milliseconds)
returns native finder object (for chaining)
finder//Exclude-path
Excludes paths that match a string substring or glob pattern.
finder native finder object
pattern string substring or glob pattern to exclude
returns native finder object (for chaining)
finder//Size>
Filters for entries with size greater than N bytes.
finder native finder object
bytes integer minimum exclusive size
returns native finder object (for chaining)
finder//Eval
Executes the find operation and returns matching paths as uris.
finder native finder object
returns block of paths; uris by default, or strings according to finder//Path-mode!
finder//Path-mode!
Sets how finder Eval returns paths: 'full (absolute string), 'relative (to cwd, string), 'filenames (basename string), or 'uris (the default).
finder native finder object
mode word or string, one of 'full, 'relative, 'filenames, or 'uris
returns native finder object (for chaining)
Additional OS utilities
Common OS operations made simple
file-size
Gets the size of a file in bytes.
path uri representing the file
returns integer size in bytes
touch
Creates a file if it doesn't exist, or updates its access time if it does.
path uri representing the file to touch
returns path uri if successful
hardlink
Creates a hard link to a file.
source uri representing the source file
link uri representing the hard link to create
returns link uri if successful
count-dir
Counts the number of files and directories in a directory.
path uri representing the directory (optional, defaults to current dir)
returns integer count of items
pid?
Gets the current process ID.
no arguments
returns integer process ID
ppid?
Gets the parent process ID.
no arguments
returns integer parent process ID
sleep
Sleeps for the specified number of seconds.
duration integer seconds to sleep
returns integer seconds slept
Network Interface Functions
Inspecting local network interfaces.
net-interface?
Looks up a network interface by name and returns it as a native object.
name String name of the network interface (e.g., "eth0", "tailscale0", "lo")
returns native net-iface object representing the interface, or error if not found
net-iface//Addrs?
Returns a block of network addresses assigned to the interface.
iface Native net-iface object
returns block of native net-addr objects assigned to the interface, or error
; iface: net-interface-by-name "lo"
; addrs: iface .Addrs?
net-addr//IPNet?
Type-asserts a network address to *net.IPNet (CIDR form). Returns failure if the address is not an IP network.
addr Native net-addr object (from net-iface//Addrs)
returns native net-ipnet object if the address is an IP network, or failure if it is; a plain net.Addr (e.g., a point-to-point address not yet assigned)
; addr: iface .Addrs? |first
; ipnet: addr .IPNet?
net-ipnet//Loopback?
Reports whether the IP address in the IPNet is a loopback address.
ipnet Native net-ipnet object
returns boolean – true if the IP is a loopback address, false otherwise
; ipnet .Loopback? ; returns true for 127.0.0.1/8
net-ipnet//IPv4?
Reports whether the IP address in the IPNet is an IPv4 address (IP.To4() != nil).
ipnet Native net-ipnet object
returns boolean – true if the IP address is IPv4, false if it is IPv6-only
; ipnet .IPv4? ; returns true when the address is an IPv4 address
net-ipnet//IP-string?
Returns the IP address contained in the IPNet as a dotted-decimal (or colon-separated) string.
ipnet Native net-ipnet object
returns string representation of the IP address (without the prefix length)
; ipnet .IP-string? ; returns "100.64.0.1"
HTTP
Working with HTTP servers and requests.
HTTP Server Functions
Working with HTTP servers and requests.
http-server
Creates a new HTTP server that listens on the specified address with a 10-second read header timeout.
addr String containing the server address (e.g., "
returns native Go-server object that can handle HTTP requests
http-server ":8080" |type?
; returns native
http-server 8080
; correctly causes error:
; `http-server` expected String for argument 1
Go-server//Serve
Starts the HTTP server listening and serving requests on the configured address (blocking call).
server Native Go-server object created by http-server
returns the server object after starting listening, or error if unable to serve
srv: http-server ":8080"
srv .Serve
Go-server//Handle
Registers an HTTP handler for a specific path pattern on the server, accepting string responses, Rye functions, or native Go handlers.
server Native Go-server object
path String URL path to handle (e.g., "/", "/api", "/static")
handler String (simple response), Function (w req -> response), or Native HTTP handler
returns the server object to allow method chaining
srv: http-server ":8080"
srv .Handle "/" "Hello World!"
srv .Handle "/api" fn { w req } { w .Write "API response" }
HTTP Response Writer Functions
Writing HTTP responses and setting headers.
Go-server-response-writer//Write
Writes string content to the HTTP response body, used within HTTP request handlers to send response data to clients.
writer Native Go-server-response-writer object from HTTP handler
content String content to write to the HTTP response body
returns the response writer object for method chaining
; Inside a handler function { w req }:
; write w "Hello World!"
; w .Write "Response content"
Go-server-response-writer//Set-content-type
Sets the Content-Type header for the HTTP response, determining how the browser interprets the response data.
writer Native Go-server-response-writer object from HTTP handler
contentType String MIME type (e.g., "text/html", "application/json", "image/png")
returns the response writer object for method chaining
; Inside a handler: w .Set-content-type "application/json"
; Inside a handler: w .Set-content-type "text/html"
Go-server-response-writer//Set-header
Sets a custom HTTP header in the response, allowing control over caching, security, and other HTTP behaviors.
writer Native Go-server-response-writer object from HTTP handler
name Word representing the header name (e.g., 'cache-control, 'x-custom-header)
value String value to set for the header
returns the response writer object for method chaining
; Inside a handler: w .Set-header 'cache-control "no-cache"
; Inside a handler: w .Set-header 'x-custom-header "custom-value"
Go-server-response-writer//Add-header
Adds a custom HTTP header value in the response, preserving existing values for multi-value headers.
writer Native Go-server-response-writer object from HTTP handler
name Word representing the header name (e.g., 'set-cookie, 'vary)
value String value to add for the header
returns the response writer object for method chaining
; Inside a handler: w .Add-header 'set-cookie "a=1; Path=/; HttpOnly"
; Inside a handler: w .Add-header 'vary "Accept-Encoding"
Go-server-response-writer//Write-header
Sets the HTTP status code for the response (must be called before writing response body).
writer Native Go-server-response-writer object from HTTP handler
code Integer HTTP status code (200=OK, 404=Not Found, 500=Internal Server Error, etc.)
returns the response writer object for method chaining
; Inside a handler: w .Write-header 404
; Inside a handler: w .Write-header 200
; Inside a handler: w .Write-header 500
Go-server//Handle-ws
Registers a WebSocket handler for a specific path pattern on the server, upgrading HTTP connections to WebSocket protocol.
server Native Go-server object
path String URL path to handle WebSocket connections (e.g., "/ws")
handler Function that receives a WebSocket connection object
returns the server object to allow method chaining
; srv: http-server ":8080"
; srv .Handle-ws "/ws" fn { conn } { forever { msg: conn .Read , conn .Write "GOT: " + msg } }
Go-server-websocket//Read
Reads a message from a WebSocket connection, blocking until data is available or an error occurs.
conn Native Go-server-websocket connection object
returns string containing the message read from the WebSocket, or error if read fails
; conn .Read ; returns the message string received from the WebSocket client
Go-server-websocket//Write
Writes a message to a WebSocket connection, sending data to the connected client.
conn Native Go-server-websocket connection object
message String message to send to the WebSocket client
returns the message string on success, or error if write fails
; conn .Write "Hello from server"
HTTP Request Functions
Extracting data from HTTP requests.
Go-server-request//Query?
Retrieves a query parameter value from the HTTP request URL (e.g., from ?name=value&other=data).
request Native Go-server-request object from HTTP handler
key String name of the query parameter to retrieve
returns string value of the query parameter, or error if key is missing
; Inside a handler with request URL "/api?name=john&age=25":
; equal { req .Query? "name" } "john"
; equal { req .Query? "age" } "25"
; error { req .Query? "missing" }
Go-server-request//Header?
Gets a header value from the HTTP request by name.
request Native Go-server-request object from HTTP handler
name String header name to retrieve (e.g., "authorization", "content-type")
returns string header value (empty string if header is missing)
; Inside a handler: req .Header? "authorization"
; Inside a handler: req .Header? "content-type"
Go-server-request//Basic-auth?
Gets HTTP Basic Authentication credentials from the request as [username password].
request Native Go-server-request object from HTTP handler
returns block with username and password strings when Basic Auth is present; error when Basic Auth credentials are missing
; Inside a handler: creds: req .Basic-auth?
; user: creds |first
; pass: creds |second
Go-server-request//Method?
Gets the HTTP request method.
request Native Go-server-request object from HTTP handler
returns string containing HTTP method (GET, POST, PUT, DELETE, ...)
; Inside a handler: req .Method?
; equal { req .Method? } "GET"
Go-server-request//Read-body
Reads the HTTP request body as a string.
request Native Go-server-request object from HTTP handler
returns string containing the request body
; Inside a handler: body: req .Read-body
; Inside a handler: print body
Go-server-request//Headers?
Gets all HTTP request headers as a dictionary.
request Native Go-server-request object from HTTP handler
returns dict containing all request headers
; Inside a handler: req .Headers?
; Inside a handler: req .Headers? |print
Go-server-request//Url?
Extracts the URL object from an HTTP request, providing access to path, query parameters, and other URL components.
request Native Go-server-request object from HTTP handler
returns native Go-server-url object containing the parsed request URL
; Inside a handler: url: req .Url?
; equal { url .type? } 'native
; error { "not-request" .Url? }
Go-server-url//Path?
Extracts the path component from a URL object (the part after the domain and before query parameters).
url Native Go-server-url object from request URL
returns string containing the path portion of the URL (without query parameters)
; Inside a handler with request to "/api/users/123":
; url: req .Url?
; equal { url .Path? } "/api/users/123"
; error { "not-url" .Path? }
Http-handler//Strip-prefix
Wraps an HTTP handler to strip a URL prefix from requests, useful for serving static files from a subdirectory.
handler Native Http-handler object (e.g., from new-static-handler)
prefix String URL prefix to strip from requests before passing to the handler
returns new Http-handler that strips the prefix from incoming request paths
; handler: new-static-handler %static/
; stripped: handler .Strip-prefix "/static/"
https-response//Status?
Gets the HTTP status code from a response object.
response native https-response object
returns integer containing the HTTP status code (200, 404, 500, etc.)
https-response//Status-text?
Gets the HTTP status text from a response object.
response native https-response object
returns string containing the HTTP status text (OK, Not Found, Internal Server Error, etc.)