OS

OS related functions

cwd?

Gets the current working directory.

none

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


does-exist

Checks if a file or directory exists.

path uri representing the file or directory to check

returns integer: 1 if exists, 0 if not exists

cd

Changes the current working directory.

path uri representing the directory to change to

returns the same uri if successful

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

mkdir

Creates a new directory.

path uri representing the directory to create

returns the same uri if successful

mktmp

Creates a new temporary directory.

none

returns uri representing the created temporary directory

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.

none

returns block of uris representing files and directories in the current directory

ls\

Lists files or directories in the current directory based on filter. Use 'dirs' for directories only, 'files' for files only, a string for partial name matching, or a regexp to match names.

filter 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 current directory

host-info?

Gets information about the host system.

none

returns dictionary containing information about the host system (hostname, uptime, OS, etc.)

users?

Gets information about users currently logged into the system.

none

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.

none

returns dictionary with keys "1", "5", and "15" representing load averages

virtual-memory?

Gets information about virtual memory usage.

none

returns dictionary containing information about virtual memory (total, free, used-percent)

disk-usage?

Gets disk usage information for all partitions.

none

returns table containing disk usage information for all partitions

pids?

Gets a list of all process IDs currently running.

none

returns block of integers representing process IDs

processes?

Gets detailed information about all running processes.

none

returns table containing detailed information about all running processes

process

Gets detailed information about a specific process by PID.

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.

none

returns string containing the current contents of the clipboard

Git

Git repository functions

init

Initializes a new Git repository at the specified path.

path path to Git repository

returns native Git repository object

repo: open "."
repo .git-repo//Branches? |for { -> "name" |print }
repo .git-repo//Commits? |first -> "message" |print
repo .git-repo//Remotes? |for { -> "name" |print }
repo .git-repo//Tags? |for { -> "name" |print }
wt: repo .git-repo//Worktree?
wt .git-worktree//Status? |print


clone

Clones a Git repository from the specified URL to the specified path.

url URL of the Git repository to clone

path path where to clone the repository

returns native Git repository object

git-repo//Worktree?

Gets the worktree for a Git repository.

repo Git repository object

returns native Git worktree object

git-worktree//Status?

Gets the status of a Git worktree.

worktree Git worktree object

returns dict containing the status of the worktree

git-repo//Untracked-files?

Lists all untracked files in the repository sorted by last modification time (newest first).

repo Git repository object

returns block of untracked files sorted by modification time (newest first)

git-repo//Commits?

Gets the commit history for a Git repository.

repo Git repository object

returns block of commit information

git-repo//Branches?

Gets the list of branches in a Git repository.

repo Git repository object

returns block of branch names

git-repo//Remotes?

Gets the list of remotes in a Git repository.

repo Git repository object

returns block of remote information

git-repo//Tags?

Gets the list of tags in a Git repository.

repo Git repository object

returns block of tag information

git-repo//Checkout

Checks out a branch in a Git repository.

repo Git repository object

branch Branch name to checkout

returns Git repository object

git-repo//Create-branch

Creates a new branch in a Git repository.

repo Git repository object

branch Branch name to create

returns Git repository object

git-worktree//Add

Adds a file to the Git index.

worktree Git worktree object

path Path of the file to add

returns Git worktree object

git-worktree//Commit

Commits changes to the Git repository.

worktree Git worktree object

message Commit message

author Optional author name (default

email Optional author email (default

returns Git worktree object

SSH

SSH server functions

ssh-server

Creates a new SSH server that listens on the specified address.

address String containing host

returns native SSH server object

server: ssh-server "localhost:2222"
server |Password-auth { pass = "secret123" }
server |Handle fn { session } {
session .Write "Welcome to Rye SSH server!
"
session .Write "Type 'exit' to quit.
"
}
server |Serve


ssh-server//Handle

Sets a handler function for SSH sessions on the server.

server SSH server object

handler Function that receives an SSH session object

returns the SSH server object

ssh-server//Password-auth

Sets a password authentication handler for the SSH server.

server SSH server object

handler Function that receives a password string and returns true/false

returns the SSH server object

ssh-server//Serve

Starts the SSH server, listening for connections.

server SSH server object

returns the SSH server object, or error if unable to serve

ssh-session//Write

Writes a string to an SSH session.

session SSH session object

text String to write to the session

returns the SSH session object

Default

go-with

Executes a function in a separate goroutine, passing the specified value as an argument.

value Object to pass to the goroutine function

function Function to execute in a separate goroutine, receives the value as argument

returns the original value that was passed to the goroutine

x:: 0 , go-with 5 fn { v } { change! v 'x } , sleep 100 , x
; returns 5
y:: 0 , go-with "test" fn { v } { change! length? v 'y } , sleep 100 , y
; returns 4
; Simple goroutine with channel communication
ch: channel 1
go fn { } { ch .Send "Hello from goroutine" }
print ch .Read

; Using waitgroup to coordinate multiple goroutines
wg: waitgroup
results: channel 10
loop 5 { i |
wg .Add 1
go-with i fn { n } { results .Send n * 2 , wg .Done }
}
wg .Wait
results .Close

; Mutex for safe shared state
counter:: 0
mtx: mutex
go fn { } { mtx .Lock , change! counter + 1 'counter , mtx .Unlock }


go

Executes a function in a separate goroutine without passing any arguments.

function Function to execute in a separate goroutine (takes no arguments)

returns the function that was executed

x:: 0 , go fn { } { change! 42 'x } , sleep 100 , x
; returns 42
y:: "unchanged" , go fn { } { change! "changed" 'y } , sleep 100 , y
; returns "changed"

channel

Creates a new channel with the specified buffer size for goroutine communication.

buffer-size Integer specifying the channel buffer size (0 for unbuffered)

returns a new channel native object with the specified buffer size

ch: channel 1 , ch .Send 42 , ch .Read
; returns 42
ch: channel 2 , ch .Send 1 , ch .Send 2 , ch .Read
; returns 1
channel 5 |type?
; returns native

Rye-channel//Read

Reads the next value from a channel, blocking until a value is available or the channel is closed.

channel Channel to read from

returns the next value from the channel, or an error if the channel is closed

ch: channel 1 , ch .Send 123 , ch .Read
; returns 123
ch: channel 1 , ch .Send "test" , ch .Read
; returns "test"
ch: channel 1 , ch .Close , try { ch .Read } |type?
; returns error

Rye-channel//Send

Sends a value through a channel, blocking if the channel is unbuffered or full.

channel Channel to send the value to

value Value to send through the channel

returns the channel object

ch: channel 1 , ch .Send 42 , ch .Read
; returns 42
ch: channel 3 , ch .Send "A" , ch .Send "B" , ch .Read
; returns "A"

Rye-channel//Close

Closes a channel, preventing further sends and causing pending/future reads to return an error.

channel Channel to close

returns the closed channel object

ch: channel 1 , ch .Send 42 , ch .Close , ch |type?
; returns native
ch: channel 1 , ch .Close , ch .Send 123 |disarm |type?
; returns error
ch: channel 2 , ch .Close , ch .Read |disarm |type?
; returns error

mutex

Creates a new mutex for synchronizing access to shared resources between goroutines.

(none)

returns a new mutex native object for synchronization

mutex |type?
; returns native
mtx: mutex , mtx .Lock , mtx .Unlock , mtx |type?
; returns native

waitgroup

Creates a new waitgroup for coordinating multiple goroutines to wait for completion.

(none)

returns a new waitgroup native object for coordinating goroutines

waitgroup |type?
; returns native
wg: waitgroup , wg .Add 1 , wg .Done , wg .Wait , wg |type?
; returns native

Rye-mutex//Lock

Acquires the lock on a mutex, blocking until the lock becomes available.

mutex Mutex to acquire the lock on

returns the mutex object

mtx: mutex , mtx .Lock , mtx |type?
; returns native
mtx: mutex , mtx .Lock , mtx .Unlock , mtx .Lock , mtx |type?
; returns native

Rye-mutex//Unlock

Releases the lock on a mutex, allowing other goroutines to acquire it.

mutex Mutex to release the lock from

returns the mutex object, or error if unlocking an unlocked mutex

mtx: mutex , mtx .Lock , mtx .Unlock , mtx |type?
; returns native
mtx: mutex , mtx .Unlock |disarm |type?
; returns error

Rye-waitgroup//Add

Adds the specified count to the waitgroup counter, indicating how many goroutines to wait for.

waitgroup Waitgroup to add goroutines to

count Number of goroutines to add to the wait counter

returns the waitgroup object

wg: waitgroup , wg .Add 3 , wg |type?
; returns native
wg: waitgroup , wg .Add 1 , wg .Add 2 , wg |type?
; returns native

Rye-waitgroup//Done

Decrements the waitgroup counter by one, indicating that a goroutine has completed.

waitgroup Waitgroup to decrement the counter for

returns the waitgroup object

wg: waitgroup , wg .Add 1 , wg .Done , wg |type?
; returns native
wg: waitgroup , wg .Add 2 , wg .Done , wg .Done , wg |type?
; returns native

Rye-waitgroup//Wait

Blocks until the waitgroup counter reaches zero, meaning all goroutines have completed.

waitgroup Waitgroup to wait on

returns the waitgroup object after all goroutines have completed

wg: waitgroup , wg .Add 1 , wg .Done , wg .Wait , wg |type?
; returns native
wg: waitgroup , wg .Wait , wg |type?
; returns native

select\fn

Performs a select operation on multiple channels, executing functions when channels are ready or a default function.

block Block containing channel-function pairs and optional default function

returns the original block argument