More on flags

Rye Command Line Flags

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.

Basic Command Line Flags

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

Command Patterns

Rye supports several command patterns:

  • rye - Enters the Rye console (REPL)
  • rye <filename> - Executes a Rye file
  • rye . - Executes main.rye in the current directory
  • rye <path>/. - Executes main.rye in the specified path
  • rye continue or rye cont - Continues console from the last save
  • rye here - Starts in Rye here mode (loads .rye-here file)

Powerful Flag Combinations

Let’s explore how these flags can be combined to create powerful workflows:

1. Development and Debugging

Interactive Development with Files

# 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

Context-Specific Development

# 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

2. Data Processing Workflows

CSV Processing

# 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

Combining with Here Mode

# Create a .rye-here file with common functions
# Then use those functions in one-liners
rye -do 'load-data |transform |save-results' here

3. Security Scenarios

Readonly Operations

# 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

Strict Security Profile

# 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

4. Template Processing

# 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

5. Language Dialects

# 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