Rye is a versatile programming language with a rich set of command line flags that can be combined in various ways to enhance your development experience. This guide explores the many flags available in Rye and demonstrates how they can be used together to solve different problems.
Flag | Description |
---|---|
-do <code> |
Evaluates Rye code after loading a file or last save |
-sdo <code> |
Same as -do but in silent mode (doesn’t display return values) |
-lang <dialect> |
Select a dialect/language (rye, eyr, math) |
-ctx <context> |
Enter a specific context or context chain |
-silent |
Console doesn’t display return values |
-stin <mode> |
Inject first value from stdin (modes: no, all, a) |
-console |
Enters console after a file is evaluated |
-dual |
Starts REPL in dual-mode with two parallel panels |
-template |
Process file as a template, evaluating Rye code in {{ }} blocks |
-help |
Displays help message |
Flag | Description |
---|---|
-seccomp-profile <profile> |
Seccomp profile to use: strict, readonly |
-seccomp-action <action> |
Action on restricted syscalls: errno, kill, trap, log |
Rye supports several command patterns:
rye
- Enters the Rye console (REPL)rye <filename>
- Executes a Rye filerye .
- Executes main.rye in the current directoryrye <path>/.
- Executes main.rye in the specified pathrye continue
or rye cont
- Continues console from the last saverye here
- Starts in Rye here mode (loads .rye-here file)Let’s explore how these flags can be combined to create powerful workflows:
# Load a file and enter console to interact with its contents
rye -console myprogram.rye
# Load a file, execute additional code, then enter console
rye -do 'debug-mode: true' -console myprogram.rye
# Continue from last saved state with debugging enabled
rye -do 'debug-mode: true' continue
# Start console with OS context for file operations
rye -ctx os
# Start console with multiple contexts chained
rye -ctx 'os pipes'
# Load a file in a specific context and enter console
rye -ctx 'os' -console file-processor.rye
# Load CSV, process it, and save results
rye -do 'load\csv %data.csv |where-greater "Age" 50 |save\csv %filtered.csv' -silent
# Load CSV, analyze it, and enter console for further exploration
rye -do 'data: load\csv %data.csv |autotype 1.0' -console
# Create a .rye-here file with common functions
# Then use those functions in one-liners
rye -do 'load-data |transform |save-results' here
# Run a script that should only read files, not write them
rye -seccomp-profile=readonly data-analyzer.rye
# TODO:
# Combine with strict action for maximum security
# rye -seccomp-profile=readonly -seccomp-action=kill data-analyzer.rye
# Allow reading but prevent writing in interactive mode
rye -seccomp-profile=readonly -console
# Run with strict security profile (prevents dangerous syscalls)
rye -seccomp-profile=strict my-script.rye
# TODO
# Debugging security issues with logging
# rye -seccomp-profile=strict -seccomp-action=log my-script.rye
# Process a template file, evaluating Rye code in {{ }} blocks
rye -template my-template.txt
# Process template with specific context
rye -ctx 'os' -template my-template.txt
# Process template and save result
rye -do 'result: process-template %my-template.txt; write-file %output.txt result' -silent
# Use the stack-based Eyr dialect
rye -lang eyr
# Run a math-focused script with the math dialect
rye -lang math calculations.rye
# Combine dialect with context
rye -lang eyr -ctx 'os' -console