Rye Function Reference: Baseio ( Updated: "2026-10-05" )

Browse by source file and section. Examples are generated from builtin tests.

Printing

Default

display

Interactively displays a value (Block, Dict, Table, TableRow, or Markdown) in the terminal with navigation capabilities.

Args: 1

pure

value Block, Dict, Table, TableRow, Markdown, or Error to display interactively

returns the selected value or the original value when user exits

display [1 2 3]

_..

Shorthand alias for 'display' - interactively displays a value in the terminal with navigation capabilities.

Args: 1

value Block, Dict, Table, TableRow, Markdown, or Error to display interactively

returns the selected value or the original value when user exits

_.. [1 2 3]

display\custom

Interactively displays a Table in the terminal with a custom rendering function for each row.

Args: 2

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 } |display\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.

Args: 1

values Block to format as space-separated values

returns returns the input block after printing

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.

Args: 1

values Block to format as comma-separated values

returns returns the input block after printing

print\csv { 1 2 "a" }
; prints "1,2,a
; "

Baseio

Default

scmd

Execute a shell command and return its exit status code.

Args: 1

cmd Shell command string to execute

returns integer exit status code

scmd "exit 0"
; returns 0
scmd "exit 3"
; returns 3

scmd\capture

Execute a shell command and capture the output, return it as string

Args: 1

cmd Shell command string to execute and capture output

returns string containing captured stdout (stderr on error)

scmd\capture "echo hi"
; returns "hi
; "

exit

Exits the process with the given integer status code (or 0 for any non-integer).

Args: 1

; 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).

Rye-itself//Args?

Rye-itself//Args\raw?

Returns raw command line arguments joined as a single string.

Args: 1

Rye-itself//Args\raw? _

Rye-itself//History?

Returns a block of the last N lines from REPL history.

Args: 2

Rye-itself//History? _ 10

Rye-itself//Landlock

Create a landlock builder object that can be configured and then enforced.

ll: Rye-itself//Landlock
ll | landlock//Limit-to-cwd | landlock//Enforce

Rye-itself//Unshare-config?

Returns a dictionary with unshare isolation flags: active, fs, net, pid, uts (booleans).

pure
cc Rye-itself Unshare-config? |print

capture-stdout

Executes a block of code while capturing all output to stdout, returning the captured output as a string.

Args: 1

capture-stdout { print 1 }
; returns "1
; "

IO

Console IO

Console input and output functions

input

Prompts for and reads user input from the console.

Args: 1

prompt string to display as a prompt

returns string containing the user's input

; File operations
file: Create %output.txt
file .Write "Hello, World!
"
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.

Args: 1

path uri representing the file to open

returns native file object

Open data/file.txt |kind?
; returns file

file-uri//Open\append

Opens a file for appending.

Args: 1

path uri representing the file to open for appending

returns native writer object

Open\append data/file.txt |kind?
; returns file

file-uri//Create

Creates a new file.

Args: 1

path uri representing the file to create

returns native file object

Create data/created.txt |kind?
; returns file

file-uri//Ext?

Gets the extension of a file.

Args: 1

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.

Args: 1

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.

Args: 1

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.

Args: 1

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.

Args: 1

path uri representing a file path

returns block of strings containing path components

file-uri//Is-absolute

Checks if a file path is absolute.

Args: 1

path uri representing a file path

returns boolean indicating whether the path is absolute

file-uri//Does-exist

Checks if a file exists.

Args: 1

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.

Args: 1

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.

Args: 1

source file object to read from

returns native reader object

Reader Open data/file.txt |kind?
; returns reader

file//Writer

Creates a new reader from file object.

Args: 1

source file object to read from

returns native reader object

Writer Open data/file.txt |kind?
; returns writer

file-uri//Reader

Creates a new reader from a file uri/path.

Args: 1

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.

Args: 1

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.

Args: 1

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.

Args: 1

reader native reader object

returns empty string if successful

reader//Copy

Copies all content from a reader to a writer.

Args: 2

reader native reader object

writer native writer object

returns the reader object if successful

file//Copy

Copies content from a file to a writer.

Args: 2

file native file object

writer native writer object

returns the file object if successful

file//Stat

Gets file information (stat) for a file.

Args: 1

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.

Args: 1

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.

Args: 1

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.

Args: 1

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.

Args: 2

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.

Args: 1

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.

Args: 1

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.

Args: 1

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.

Args: 1

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.

Args: 2

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.

Args: 2

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.

Args: 2

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.

Args: 2

writer native writer object

content string to write

returns the writer object if successful

HTTPs Operations

Web requests and HTTP protocol functions

https-uri//Open

Opens a HTTPS GET request and returns a reader for the response body.

Args: 1

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.

Args: 1

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.

Args: 3

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//Get

Makes a HTTP GET request and returns the response body as a string.

Args: 1

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.

Args: 3

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

https-uri//Request

Creates a new HTTPS request object.

Args: 3

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.

Args: 3

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.

Args: 3

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.

Args: 1

request native https-request object

returns native https-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.

Args: 1

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.

Args: 1

response native https-response object

returns string containing the response body

https-response//Close-body!

Closes the HTTPS response body to free network resources.

Args: 1

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.

Args: 2

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.

Args: 1

server uri representing the FTP server to connect to

returns native ftp-connection object

ftp-connection//Login

Logs in to an FTP server connection.

Args: 3

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.

Args: 2

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.

Args: 1

connection native ftp-connection object

returns integer 1 for successerror if close fails

File Monitoring

File watching and tailing operations

tail-file

Tails a file, following it for new content. Used for monitoring log files.

Args: 3

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.

Args: 1

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.

Args: 1

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.

Args: 1

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.

Args: 2

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.

Args: 1

connection native unix-connection object

returns string containing data read from the socket

unix-connection//Close

Closes a Unix domain socket connection.

Args: 1

connection native unix-connection object

returns empty string if successful

Table Files

Table files

Load and save tables as CSV, TSV or XLSX files.

file-uri//Load\csv

Loads a .csv file to a table datatype.

Args: 1

file-uri - location of csv file to load

Tags #table #loading #csv

equal {
cc os
f:: mktmp ++ "/test.csv"
spr1:: table { "a" "b" "c" } { 1 1.1 "a" 2 2.2 "b" 3 3.3 "c" }
spr1 .Save\csv* f
spr2:: Load\csv f |autotype 1.0
spr1 = spr2
} true

file-uri//Load\csv\

Loads a .csv file to a table datatype.

Args: 2

file-uri - location of csv file to load

Tags #table #loading #csv

equal {
cc os
f:: mktmp ++ "/test.csv"
spr1:: table { "a" "b" "c" } { 1 1.1 "a" 2 2.2 "b" 3 3.3 "c" }
spr1 .Save\csv* f
spr2:: Load\csv f |autotype 1.0
spr1 = spr2
} true

file-uri//Load\tsv

Loads a .csv file to a table datatype.

Args: 1

file-uri - location of csv file to load

equal {
cc os
f:: mktmp ++ "/test.tsv"
spr1:: table { "a" "b" "c" } { 1 1.1 "a" 2 2.2 "b" 3 3.3 "c" }
spr1 .Save	sv* f
spr2:: Load	sv f |autotype 1.0
spr1 = spr2
} true

file-uri//Save\csv

Saves a table to a .csv file.

Args: 2

file-uri - where to save the sheet as a .csv file

table - the table to save

Tags #table #saving #csv

equal {
cc os
f:: mktmp ++ "/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.

Args: 2

file-uri - where to save the sheet as a .tsv file

table - the table to save

Tags #table #saving #tsv

equal {
cc os
f:: mktmp ++ "/test.tsv"
spr1:: table { "a" "b" "c" } { 1 1.1 "a" 2 2.2 "b" 3 3.3 "c" }
f .Save	sv spr1
spr2:: Load	sv f |autotype 1.0
spr1 = spr2
} true

file-uri//Load\xlsx

Loads the first sheet in an .xlsx file to a Table.

Args: 1

file-uri - location of xlsx file to load

Tags #table #loading #xlsx

equal {
cc os
f:: mktmp ++ "/test.xlsx"
spr1:: table { "a" "b" "c" } { 1 1.1 "a" 2 2.2 "b" 3 3.3 "c" }
spr1 .Save\xlsx* f
spr2:: Load\xlsx f |autotype 1.0
spr1 = spr2
} true

file-uri//Save\xlsx

Saves a Table to a .xlsx file.

Args: 2

file-uri - where to save the table as a .xlsx file

table - the table to save

Tags #table #saving #xlsx

equal {
cc os
f:: mktmp ++ "/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

Command Operations

Running other programs

cmd

Create a command.

Args: 1

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.

Args: 2

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.

Args: 2

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.

Args: 2

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.

Args: 2

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.

Args: 2

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.

Args: 1

command native command object

returns boolean true if the command executed successfully

command//Start

Start a command (and any piped commands) without waiting.

Args: 1

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).

Args: 1

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).

Args: 1

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.

Args: 1

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.

Args: 1

command native command object

returns for simple command: exit status integerfor 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

Args: 1

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

Args: 1

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.

Args: 1

command native command object

returns the original command object after redirecting stdin/stdout/stderr to /dev/null

OS

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.

Args: 1

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.

Args: 1

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.

Args: 1

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.

Args: 1

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

cc os mktmp

rm

Removes a file or empty directory.

Args: 1

path uri representing the file or empty directory to remove

returns the uri if successfulTags: #file #delete

cc os rm %./tests/delme

rmdir

Removes a directory and all its contents recursively.

Args: 1

path uri representing the directory to remove (including contents)

returns the uri if successfulTags: #file #delete

cc os rmdir %./tests/delme

cp

Copies a file to a new location.

Args: 2

source uri representing the source file

destination uri representing the destination file

returns destination uri if successfulTags: #file #copy

file-info?

Gets detailed information about a file or directory.

Args: 1

path uri representing the file or directory

returns dict with keys: name, size, mode, mod-time, is-dirTags: #file #info

cc os file-info? %./tests/data/file.txt

is-dir

Checks if a path is a directory. Fails if the path does not exist.

Args: 1

path uri representing the path to check

returns boolean: true if path is a directory, false otherwise. Fails if the path does not exist.Tags: #file #check

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.

Args: 1

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.Tags: #file #check

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 directoryTags: #file #directory

cc os home-dir?

tmp-dir?

Gets the system's default temporary directory.

no arguments

returns uri representing the system's temporary directoryTags: #file #directory

cc os tmp-dir?

glob

Returns files matching a glob pattern.

Args: 1

pattern string containing a glob pattern (e.g., "*.txt", "data/*.csv")

returns block of uris matching the patternTags: #file #search

cc os glob "./tests/data/*.pem"

mv

Moves or renames a file or directory.

Args: 2

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 regexp to match names.

Args: 1

filter file-uri to list directory, word 'dirs' or 'files' to filter by type, string for partial name matching, or regexp 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 regexp to match names.

Args: 1

filter string for partial name matching, or regexp 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 regexp to match names.

Args: 1

filter string for partial name matching, or regexp 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.

Args: 2

path uri representing source path

link uri representing link path to create

returns link uri if successfulTags: #file #link

is-symlink

Checks if a path is a symbolic link. Fails if the path does not exist.

Args: 1

path uri representing a path to check

returns boolean: true if path is a symbolic linkTags: #file #check

readlink

Reads the target of a symbolic link.

Args: 1

path uri representing a symbolic link

returns uri representing the target of the symlinkTags: #file #link

chmod

Changes file or directory permissions.

Args: 2

path uri representing file or directory path

mode integer representing file mode (e.g., 0755)

returns path uri if successfulTags: #file #permissions

abs-path

Removed: use realpath instead.

Args: 1

path uri representing file or directory

returns string representing the absolute pathTags: #file #path

dirname

Returns the directory part of a path.

Args: 1

path uri representing a path

returns uri representing the directory containing the pathTags: #file #path

cc os dirname %./tests/data/file.txt

basename

Returns the filename part of a path.

Args: 1

path uri representing a path

returns string representing the filename part of the pathTags: #file #path

cc os basename %./tests/data/file.txt

file-ext

Returns the file extension of a path (including the dot).

Args: 1

path uri representing a file path

returns string representing the file extension (including the dot)Tags: #file #path

cc os file-ext %./tests/data/file.txt

join-path

Joins path elements into a single path.

Args: 1

paths uri or block of uris to join

returns uri representing the joined pathTags: #file #path

cc os join-path { %./tests "data" "file.txt" }

whoami

Returns the current user's username.

no arguments

returns string representing the current user's usernameTags: #system #user

cc os whoami

which

Finds the path to an executable command.

Args: 1

command string representing the command to check

returns uri representing the path to the executable, or error if not foundTags: #system #command

cc os which "sh"

cp-r

Recursively copies a directory and all its contents.

Args: 2

source uri representing source directory

destination uri representing destination directory

returns destination uri if successfulTags: #file #copy #recursive

mkdir-p

Creates a directory and any necessary parent directories.

Args: 1

path uri representing directory path to create

returns path uri if successfulTags: #file #directory

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?).

Args: 1

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.

Args: 1

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.

Args: 1

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.

Args: 1

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

tgz

Creates a .tar.gz archive from a file or directory.

Args: 2

source uri representing the file or directory to archive

destination uri representing the output .tar.gz file

returns destination uri if successfulTags: #archive #compress

un-tgz

Removed: use untgz instead.

Args: 2

source uri representing the .tar.gz file

destination uri representing the output directory

returns destination uri if successfulTags: #archive #extract

zip

Creates a .zip archive from a file or directory.

Args: 2

source uri representing the file or directory to archive

destination uri representing the output .zip file

returns destination uri if successfulTags: #archive #compress

unzip

Extracts a .zip archive to a directory.

Args: 2

source uri representing the .zip file

destination uri representing the output directory

returns destination uri if successfulTags: #archive #extract

find

Removed: use new-finder instead.

Args: 1

path uri or block of uris representing starting paths

returns native finder objectTags: #find #files

finder//Min-depth!

Sets the minimum depth for file traversal.

Args: 2

finder native finder object

depth integer minimum depth

returns native finder object (for chaining)Tags: #find #filter

finder//Max-depth!

Sets the maximum depth for file traversal.

Args: 2

finder native finder object

depth integer maximum depth

returns native finder object (for chaining)Tags: #find #filter

finder//Type

Filters results by type: 'file (or "f") for files, 'dir (or "d") for directories.

Args: 2

finder native finder object

type word 'file or 'dir (or string "f" or "d")

returns native finder object (for chaining)Tags: #find #filter

finder//Name

Filters results by file name using a glob pattern.

Args: 2

finder native finder object

pattern string glob pattern (e.g., "*.go", "test_*")

returns native finder object (for chaining)Tags: #find #filter

finder//Whole-name

Filters results by full path using a glob pattern.

Args: 2

finder native finder object

pattern string glob pattern for the whole path

returns native finder object (for chaining)Tags: #find #filter

finder//Regex

Filters results by regular expression on the full path.

Args: 2

finder native finder object

regex native regexp object

returns native finder object (for chaining)Tags: #find #filter

finder//Empty

Filters for empty files or directories.

Args: 1

finder native finder object

returns native finder object (for chaining)Tags: #find #filter

finder//Mtime-since!

Filters for files modified within the last N seconds (i.e., since now-N).

Args: 2

finder native finder object

returns block of uris representing found files/directoriesTags: #find #execute

file-size

Gets the size of a file in bytes.

Args: 1

path uri representing the file

returns integer size in bytesTags: #file #size

touch

Creates a file if it doesn't exist, or updates its access time if it does.

Args: 1

path uri representing the file to touch

returns path uri if successfulTags: #file #create

hardlink

Creates a hard link to a file.

Args: 2

source uri representing the source file

link uri representing the hard link to create

returns link uri if successfulTags: #file #link

count-dir

Counts the number of files and directories in a directory.

Args: 1

path uri representing the directory (optional, defaults to current dir)

returns integer count of itemsTags: #file #count

pid?

Gets the current process ID.

no arguments

returns integer process IDTags: #system #process

ppid?

Gets the parent process ID.

no arguments

returns integer parent process IDTags: #system #process

sleep

Sleeps for the specified number of seconds.

Args: 1

duration integer seconds to sleep

returns integer seconds sleptTags: #system #time

net-interface?

Looks up a network interface by name and returns it as a native object.

Args: 1

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.

Args: 1

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.

Args: 1

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 isa 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.

Args: 1

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).

Args: 1

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.

Args: 1

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

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.

Args: 1

addr String containing the server address (e.g., "

returns native Go-server object that can handle HTTP requests

Go-server//Serve

Starts the HTTP server listening and serving requests on the configured address (blocking call).

Args: 1

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.

Args: 3

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" }

Go-server-response-writer//Write

Writes string content to the HTTP response body, used within HTTP request handlers to send response data to clients.

Args: 2

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.

Args: 2

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.

Args: 3

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.

Args: 3

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).

Args: 2

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.

Args: 3

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.

Args: 1

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.

Args: 2

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"

Go-server-request//Query?

Retrieves a query parameter value from the HTTP request URL (e.g., from ?name=value&other=data).

Args: 2

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.

Args: 2

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].

Args: 1

request Native Go-server-request object from HTTP handler

returns block with username and password strings when Basic Auth is presenterror 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.

Args: 1

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.

Args: 1

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.

Args: 1

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.

Args: 1

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).

Args: 1

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.

Args: 2

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.

Args: 1

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.

Args: 1

response native https-response object

returns string containing the HTTP status text (OK, Not Found, Internal Server Error, etc.)