UPdate.
Some checks failed
WrenCI / mac (push) Waiting to run
WrenCI / windows (push) Waiting to run
WrenCI / linux (push) Failing after 55s

This commit is contained in:
retoor 2026-01-26 05:12:14 +01:00
parent a59dbe1d55
commit fe2f087d9f
143 changed files with 13333 additions and 15112 deletions

View File

@ -1,6 +1,6 @@
# retoor <retoor@molodetz.nl>
.PHONY: build tests clean debug sync-sidebar buildmanual
.PHONY: build tests clean debug sync-sidebar buildmanual wasm wasm-clean install-emscripten
build:
cd projects/make && $(MAKE) -f wren_cli.make -j $$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)
@ -26,5 +26,27 @@ install:
clean:
cd projects/make && $(MAKE) -f wren_cli.make clean
wasm-clean:
cd projects/make.wasm && $(MAKE) -f wren_wasm.make clean
install-emscripten:
@if [ ! -d "$(HOME)/emsdk" ]; then \
echo "Cloning Emscripten SDK..."; \
git clone https://github.com/emscripten-core/emsdk.git $(HOME)/emsdk; \
cd $(HOME)/emsdk && ./emsdk install latest && ./emsdk activate latest; \
echo ""; \
echo "Emscripten installed. Run: source ~/emsdk/emsdk_env.sh"; \
else \
echo "Emscripten SDK already exists at ~/emsdk"; \
echo "Run: source ~/emsdk/emsdk_env.sh"; \
fi
wasm:
@if [ -z "$$EMSDK" ]; then \
echo "Error: EMSDK is not set. Run 'source ~/emsdk/emsdk_env.sh' first"; \
exit 1; \
fi
cd projects/make.wasm && $(MAKE) -f wren_wasm.make -j $$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)
buildmanual:
python3 util/build_manual.py

View File

@ -41,6 +41,16 @@ Run a specific test suite:
python3 util/test.py json
```
## Build Targets
| Target | Description |
|--------|-------------|
| `make build` | Release build |
| `make debug` | Debug build |
| `make clean` | Clean build artifacts |
| `make tests` | Build and run all tests |
| `make buildmanual` | Build documentation to `bin/manual/` |
## Usage
```bash
@ -56,7 +66,34 @@ bin/wren_cli # Start the REPL
## Documentation
See the `manual/` directory for the full reference including API docs, tutorials, and how-to guides.
### Building the Manual
```bash
make buildmanual
```
Output: `bin/manual/` (open `index.html` in a browser)
The manual works offline when opened directly via `file://` protocol.
### Manual Source Structure
```
manual_src/
data/
site.yaml # Site metadata (name, version)
navigation.yaml # Navigation structure and page list
templates/ # Jinja2 base templates
pages/ # Content pages (api/, tutorials/, howto/, etc.)
static/ # CSS, JS assets
```
### Adding Documentation for a New Module
1. Create `manual_src/pages/api/<name>.html` using the template from an existing API page
2. Add entry to `manual_src/data/navigation.yaml` under the API Reference section
3. Update `prev_page`/`next_page` in adjacent API pages
4. Build: `make buildmanual`
## License

View File

@ -1215,6 +1215,7 @@ static WrenInterpretResult runInterpreter(WrenVM* vm, register ObjFiber* fiber)
CASE_CODE(RETURN):
{
Value result = POP();
WREN_PROFILE_EXIT(fiber);
fiber->numFrames--;
// Close any upvalues still in scope.

View File

@ -6,6 +6,22 @@
#include "wren_value.h"
#include "wren_utils.h"
#ifdef WREN_PROFILE_ENABLED
struct ProfileEntry;
struct ProfileFrame;
struct ProfileState;
extern struct ProfileState* g_profile;
void wrenProfileEnter(WrenVM* vm, ObjFiber* fiber, ObjClosure* closure);
void wrenProfileExit(ObjFiber* fiber);
#define WREN_PROFILE_ENTER(vm, fiber, closure) \
do { if (g_profile) wrenProfileEnter(vm, fiber, closure); } while(0)
#define WREN_PROFILE_EXIT(fiber) \
do { if (g_profile) wrenProfileExit(fiber); } while(0)
#else
#define WREN_PROFILE_ENTER(vm, fiber, closure) ((void)0)
#define WREN_PROFILE_EXIT(fiber) ((void)0)
#endif
// The maximum number of temporary objects that can be made visible to the GC
// at one time.
#define WREN_MAX_TEMP_ROOTS 8
@ -193,6 +209,7 @@ static inline void wrenCallFunction(WrenVM* vm, ObjFiber* fiber,
wrenEnsureStack(vm, fiber, needed);
wrenAppendCallFrame(vm, fiber, closure, fiber->stackTop - numArgs);
WREN_PROFILE_ENTER(vm, fiber, closure);
}
// Marks [obj] as a GC root so that it doesn't get collected.

36
example/os_demo.wren vendored Normal file
View File

@ -0,0 +1,36 @@
// retoor <retoor@molodetz.nl>
import "os" for Platform, Process
System.print("=== OS Module Demo ===\n")
System.print("--- Platform Information ---")
System.print("Name: %(Platform.name)")
System.print("Is POSIX: %(Platform.isPosix)")
System.print("Is Windows: %(Platform.isWindows)")
System.print("Home Path: %(Platform.homePath)")
System.print("\n--- Process Information ---")
System.print("PID: %(Process.pid)")
System.print("Parent PID: %(Process.ppid)")
System.print("Working Directory: %(Process.cwd)")
System.print("Wren Version: %(Process.version)")
System.print("\n--- Command Line Arguments ---")
System.print("Arguments: %(Process.arguments)")
System.print("All Arguments: %(Process.allArguments)")
System.print("\n--- Platform-Specific Paths ---")
var separator = Platform.isWindows ? "\\" : "/"
var configPath = Platform.homePath + separator + ".config"
System.print("Config directory: %(configPath)")
System.print("\n--- Conditional Exit ---")
var args = Process.arguments
if (args.count > 0 && args[0] == "--fail") {
System.print("Exiting with error code 1")
Process.exit(1)
}
System.print("Exiting normally")
Process.exit(0)

View File

@ -1,6 +1,6 @@
// retoor <retoor@molodetz.nl>
import "regex" for Regex
import "regex" for Regex, Match
System.print("=== Regex Module Demo ===\n")
@ -128,3 +128,35 @@ var sentence = "hello, world; foo bar"
var tokens = tokenSeparator.split(sentence)
System.print("Input: %(sentence)")
System.print("Tokens: %(tokens)")
System.print("\n--- Match Object ---")
var emailRe = Regex.new("(\\w+)@(\\w+)\\.(\\w+)")
var match = emailRe.match("Contact: alice@example.com for info")
if (match != null) {
System.print("Full match: %(match.text)")
System.print("Start index: %(match.start)")
System.print("End index: %(match.end)")
System.print("group(0): %(match.group(0))")
System.print("group(1): %(match.group(1))")
System.print("group(2): %(match.group(2))")
System.print("group(3): %(match.group(3))")
}
System.print("\n--- Groups Property ---")
var dateRe = Regex.new("(\\d{4})-(\\d{2})-(\\d{2})")
var dateMatch = dateRe.match("Date: 2024-01-15")
if (dateMatch != null) {
System.print("groups[0] (full match): %(dateMatch.groups[0])")
System.print("groups[1] (year): %(dateMatch.groups[1])")
System.print("groups[2] (month): %(dateMatch.groups[2])")
System.print("groups[3] (day): %(dateMatch.groups[3])")
System.print("Total groups: %(dateMatch.groups.count)")
}
System.print("\n--- Find All Matches ---")
var numRe = Regex.new("\\d+")
var allMatches = numRe.matchAll("Order 123 has 5 items at $99 each")
System.print("Found %(allMatches.count) numbers:")
for (m in allMatches) {
System.print(" '%(m.text)' at position %(m.start)-%(m.end)")
}

View File

@ -1,306 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>base64 - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html" class="active">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>base64</span>
</nav>
<article>
<h1>base64</h1>
<p>The <code>base64</code> module provides Base64 encoding and decoding functionality, including URL-safe variants.</p>
<pre><code>import "base64" for Base64</code></pre>
<h2>Base64 Class</h2>
<div class="class-header">
<h3>Base64</h3>
<p>Base64 encoding and decoding utilities</p>
</div>
<h3>Static Methods</h3>
<div class="method-signature">
<span class="method-name">Base64.encode</span>(<span class="param">data</span>) &#8594; <span class="type">String</span>
</div>
<p>Encodes data to standard Base64.</p>
<ul class="param-list">
<li><span class="param-name">data</span> <span class="param-type">(String)</span> - Data to encode</li>
<li><span class="returns">Returns:</span> Base64-encoded string</li>
</ul>
<pre><code>var encoded = Base64.encode("Hello, World!")
System.print(encoded) // SGVsbG8sIFdvcmxkIQ==</code></pre>
<div class="method-signature">
<span class="method-name">Base64.decode</span>(<span class="param">data</span>) &#8594; <span class="type">String</span>
</div>
<p>Decodes a Base64-encoded string.</p>
<ul class="param-list">
<li><span class="param-name">data</span> <span class="param-type">(String)</span> - Base64 string to decode</li>
<li><span class="returns">Returns:</span> Decoded data as a string</li>
</ul>
<pre><code>var decoded = Base64.decode("SGVsbG8sIFdvcmxkIQ==")
System.print(decoded) // Hello, World!</code></pre>
<div class="method-signature">
<span class="method-name">Base64.encodeUrl</span>(<span class="param">data</span>) &#8594; <span class="type">String</span>
</div>
<p>Encodes data to URL-safe Base64. Replaces <code>+</code> with <code>-</code>, <code>/</code> with <code>_</code>, and removes padding.</p>
<ul class="param-list">
<li><span class="param-name">data</span> <span class="param-type">(String)</span> - Data to encode</li>
<li><span class="returns">Returns:</span> URL-safe Base64 string (no padding)</li>
</ul>
<pre><code>var encoded = Base64.encodeUrl("Hello, World!")
System.print(encoded) // SGVsbG8sIFdvcmxkIQ</code></pre>
<div class="method-signature">
<span class="method-name">Base64.decodeUrl</span>(<span class="param">data</span>) &#8594; <span class="type">String</span>
</div>
<p>Decodes a URL-safe Base64 string. Handles strings with or without padding.</p>
<ul class="param-list">
<li><span class="param-name">data</span> <span class="param-type">(String)</span> - URL-safe Base64 string to decode</li>
<li><span class="returns">Returns:</span> Decoded data as a string</li>
</ul>
<pre><code>var decoded = Base64.decodeUrl("SGVsbG8sIFdvcmxkIQ")
System.print(decoded) // Hello, World!</code></pre>
<h2>Encoding Comparison</h2>
<table>
<tr>
<th>Method</th>
<th>Alphabet</th>
<th>Padding</th>
<th>Use Case</th>
</tr>
<tr>
<td><code>encode</code></td>
<td>A-Z, a-z, 0-9, +, /</td>
<td>Yes (=)</td>
<td>General purpose, email, file storage</td>
</tr>
<tr>
<td><code>encodeUrl</code></td>
<td>A-Z, a-z, 0-9, -, _</td>
<td>No</td>
<td>URLs, filenames, JWT tokens</td>
</tr>
</table>
<h2>Examples</h2>
<h3>Basic Encoding and Decoding</h3>
<pre><code>import "base64" for Base64
var original = "The quick brown fox jumps over the lazy dog"
var encoded = Base64.encode(original)
System.print("Encoded: %(encoded)")
var decoded = Base64.decode(encoded)
System.print("Decoded: %(decoded)")
System.print("Match: %(original == decoded)")</code></pre>
<h3>Binary Data Encoding</h3>
<pre><code>import "base64" for Base64
var binaryData = String.fromCodePoint(0) +
String.fromCodePoint(1) +
String.fromCodePoint(255)
var encoded = Base64.encode(binaryData)
System.print("Encoded binary: %(encoded)")
var decoded = Base64.decode(encoded)
System.print("Byte 0: %(decoded.bytes[0])")
System.print("Byte 1: %(decoded.bytes[1])")
System.print("Byte 2: %(decoded.bytes[2])")</code></pre>
<h3>URL-Safe Encoding for Tokens</h3>
<pre><code>import "base64" for Base64
import "crypto" for Crypto, Hash
var data = "user:12345"
var token = Base64.encodeUrl(data)
System.print("Token: %(token)")
var decodedToken = Base64.decodeUrl(token)
System.print("Decoded: %(decodedToken)")</code></pre>
<h3>HTTP Basic Authentication</h3>
<pre><code>import "base64" for Base64
import "http" for Http
var username = "alice"
var password = "secret123"
var credentials = Base64.encode("%(username):%(password)")
var headers = {
"Authorization": "Basic %(credentials)"
}
var response = Http.get("https://api.example.com/protected", headers)
System.print(response.body)</code></pre>
<h3>Data URI Encoding</h3>
<pre><code>import "base64" for Base64
import "io" for File
var imageData = File.read("image.png")
var encoded = Base64.encode(imageData)
var dataUri = "data:image/png;base64,%(encoded)"
System.print(dataUri)</code></pre>
<h3>JWT-Style Token Parts</h3>
<pre><code>import "base64" for Base64
import "json" for Json
var header = {"alg": "HS256", "typ": "JWT"}
var payload = {"sub": "1234567890", "name": "John Doe"}
var headerB64 = Base64.encodeUrl(Json.stringify(header))
var payloadB64 = Base64.encodeUrl(Json.stringify(payload))
System.print("Header: %(headerB64)")
System.print("Payload: %(payloadB64)")</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>Base64 encoding increases data size by approximately 33%. A 3-byte input becomes 4 Base64 characters.</p>
</div>
<div class="admonition tip">
<div class="admonition-title">Tip</div>
<p>Use <code>encodeUrl</code> and <code>decodeUrl</code> when the encoded string will be used in URLs, query parameters, or filenames where <code>+</code>, <code>/</code>, and <code>=</code> characters may cause issues.</p>
</div>
</article>
<footer class="page-footer">
<a href="json.html" class="prev">json</a>
<a href="regex.html" class="next">regex</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,289 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>dns - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html" class="active">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>dns</span>
</nav>
<article>
<h1>dns</h1>
<p>The <code>dns</code> module provides DNS resolution functionality for looking up hostnames and resolving them to IP addresses.</p>
<pre><code>import "dns" for Dns</code></pre>
<h2>Dns Class</h2>
<div class="class-header">
<h3>Dns</h3>
<p>DNS resolution utilities</p>
</div>
<h3>Static Methods</h3>
<div class="method-signature">
<span class="method-name">Dns.lookup</span>(<span class="param">hostname</span>) &#8594; <span class="type">String</span>
</div>
<p>Resolves a hostname to an IP address. Uses the system's default address family preference.</p>
<ul class="param-list">
<li><span class="param-name">hostname</span> <span class="param-type">(String)</span> - Hostname to resolve</li>
<li><span class="returns">Returns:</span> IP address as a string</li>
</ul>
<pre><code>var ip = Dns.lookup("example.com")
System.print(ip) // 93.184.216.34</code></pre>
<div class="method-signature">
<span class="method-name">Dns.lookup</span>(<span class="param">hostname</span>, <span class="param">family</span>) &#8594; <span class="type">String</span>
</div>
<p>Resolves a hostname to an IP address with a specific address family.</p>
<ul class="param-list">
<li><span class="param-name">hostname</span> <span class="param-type">(String)</span> - Hostname to resolve</li>
<li><span class="param-name">family</span> <span class="param-type">(Num)</span> - Address family: 0 (any), 4 (IPv4), or 6 (IPv6)</li>
<li><span class="returns">Returns:</span> IP address as a string</li>
</ul>
<pre><code>var ipv4 = Dns.lookup("example.com", 4)
System.print(ipv4) // 93.184.216.34
var ipv6 = Dns.lookup("example.com", 6)
System.print(ipv6) // 2606:2800:220:1:248:1893:25c8:1946</code></pre>
<h3>Address Family Values</h3>
<table>
<tr>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td><code>0</code></td>
<td>Any (system default, typically prefers IPv4)</td>
</tr>
<tr>
<td><code>4</code></td>
<td>IPv4 only</td>
</tr>
<tr>
<td><code>6</code></td>
<td>IPv6 only</td>
</tr>
</table>
<h2>Examples</h2>
<h3>Basic DNS Lookup</h3>
<pre><code>import "dns" for Dns
var domains = ["example.com", "google.com", "github.com"]
for (domain in domains) {
var ip = Dns.lookup(domain)
System.print("%(domain) -> %(ip)")
}</code></pre>
<h3>IPv4 vs IPv6</h3>
<pre><code>import "dns" for Dns
var hostname = "google.com"
var ipv4 = Dns.lookup(hostname, 4)
System.print("IPv4: %(ipv4)")
var fiber = Fiber.new {
return Dns.lookup(hostname, 6)
}
var result = fiber.try()
if (fiber.error != null) {
System.print("IPv6: Not available")
} else {
System.print("IPv6: %(result)")
}</code></pre>
<h3>Using with Socket Connection</h3>
<pre><code>import "dns" for Dns
import "net" for Socket
var hostname = "httpbin.org"
var ip = Dns.lookup(hostname, 4)
System.print("Connecting to %(hostname) (%(ip))")
var socket = Socket.connect(ip, 80)
socket.write("GET /ip HTTP/1.1\r\nHost: %(hostname)\r\nConnection: close\r\n\r\n")
var response = ""
while (true) {
var data = socket.read()
if (data == null) break
response = response + data
}
socket.close()
System.print(response)</code></pre>
<h3>Using with TLS Connection</h3>
<pre><code>import "dns" for Dns
import "tls" for TlsSocket
var hostname = "example.com"
var ip = Dns.lookup(hostname, 4)
var socket = TlsSocket.connect(ip, 443, hostname)
socket.write("GET / HTTP/1.1\r\nHost: %(hostname)\r\nConnection: close\r\n\r\n")
var response = socket.read()
System.print(response)
socket.close()</code></pre>
<h3>Error Handling</h3>
<pre><code>import "dns" for Dns
var fiber = Fiber.new {
return Dns.lookup("nonexistent.invalid.domain")
}
var result = fiber.try()
if (fiber.error != null) {
System.print("DNS lookup failed: %(fiber.error)")
} else {
System.print("Resolved to: %(result)")
}</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>DNS lookups are asynchronous operations that use libuv's thread pool. The calling fiber will suspend until the lookup completes.</p>
</div>
<div class="admonition warning">
<div class="admonition-title">Warning</div>
<p>The hostname must be a string. Passing a non-string value will abort the fiber with an error. Similarly, the family parameter must be 0, 4, or 6.</p>
</div>
</article>
<footer class="page-footer">
<a href="net.html" class="prev">net</a>
<a href="json.html" class="next">json</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,294 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>json - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html" class="active">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>json</span>
</nav>
<article>
<h1>json</h1>
<p>The <code>json</code> module provides JSON parsing and stringification. It uses the cJSON library for parsing and implements stringify in Wren.</p>
<pre><code>import "json" for Json</code></pre>
<h2>Json Class</h2>
<div class="class-header">
<h3>Json</h3>
<p>JSON parsing and stringification</p>
</div>
<h3>Static Methods</h3>
<div class="method-signature">
<span class="method-name">Json.parse</span>(<span class="param">string</span>) → <span class="type">Map|List|String|Num|Bool|null</span>
</div>
<p>Parses a JSON string and returns the corresponding Wren value.</p>
<ul class="param-list">
<li><span class="param-name">string</span> <span class="param-type">(String)</span> - JSON string to parse</li>
<li><span class="returns">Returns:</span> Parsed value (Map, List, String, Num, Bool, or null)</li>
</ul>
<pre><code>var data = Json.parse('{"name": "Alice", "age": 30}')
System.print(data["name"]) // Alice
System.print(data["age"]) // 30
var list = Json.parse('[1, 2, 3]')
System.print(list[0]) // 1</code></pre>
<div class="method-signature">
<span class="method-name">Json.stringify</span>(<span class="param">value</span>) → <span class="type">String</span>
</div>
<p>Converts a Wren value to a JSON string (compact, no whitespace).</p>
<ul class="param-list">
<li><span class="param-name">value</span> <span class="param-type">(any)</span> - Value to stringify</li>
<li><span class="returns">Returns:</span> JSON string</li>
</ul>
<pre><code>var json = Json.stringify({"name": "Alice", "age": 30})
System.print(json) // {"name":"Alice","age":30}</code></pre>
<div class="method-signature">
<span class="method-name">Json.stringify</span>(<span class="param">value</span>, <span class="param">indent</span>) → <span class="type">String</span>
</div>
<p>Converts a Wren value to a formatted JSON string with indentation.</p>
<ul class="param-list">
<li><span class="param-name">value</span> <span class="param-type">(any)</span> - Value to stringify</li>
<li><span class="param-name">indent</span> <span class="param-type">(Num|String)</span> - Number of spaces or indent string</li>
<li><span class="returns">Returns:</span> Formatted JSON string</li>
</ul>
<pre><code>var json = Json.stringify({"name": "Alice"}, 2)
System.print(json)
// {
// "name": "Alice"
// }
var json2 = Json.stringify({"name": "Bob"}, "\t")
// Uses tab for indentation</code></pre>
<h2>Type Mapping</h2>
<table>
<tr>
<th>JSON Type</th>
<th>Wren Type</th>
</tr>
<tr>
<td>object</td>
<td>Map</td>
</tr>
<tr>
<td>array</td>
<td>List</td>
</tr>
<tr>
<td>string</td>
<td>String</td>
</tr>
<tr>
<td>number</td>
<td>Num</td>
</tr>
<tr>
<td>true/false</td>
<td>Bool</td>
</tr>
<tr>
<td>null</td>
<td>null</td>
</tr>
</table>
<h2>Examples</h2>
<h3>Parsing JSON</h3>
<pre><code>import "json" for Json
var jsonString = '{"users": [{"name": "Alice"}, {"name": "Bob"}]}'
var data = Json.parse(jsonString)
for (user in data["users"]) {
System.print("User: %(user["name"])")
}</code></pre>
<h3>Building and Stringifying</h3>
<pre><code>import "json" for Json
var data = {
"name": "Product",
"price": 29.99,
"tags": ["electronics", "sale"],
"inStock": true,
"metadata": null
}
System.print(Json.stringify(data, 2))</code></pre>
<h3>Nested Structures</h3>
<pre><code>import "json" for Json
var config = {
"server": {
"host": "localhost",
"port": 8080
},
"database": {
"url": "sqlite://data.db"
}
}
var json = Json.stringify(config)
System.print(json)
var parsed = Json.parse(json)
System.print(parsed["server"]["port"]) // 8080</code></pre>
<h3>Special Values</h3>
<pre><code>import "json" for Json
var special = {
"infinity": 1/0,
"nan": 0/0
}
System.print(Json.stringify(special))
// {"infinity":null,"nan":null}
// Infinity and NaN are converted to null</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>Map keys are converted to strings in JSON output. Non-string keys will have their <code>toString</code> method called.</p>
</div>
<div class="admonition warning">
<div class="admonition-title">Warning</div>
<p>Invalid JSON strings will cause a runtime error. Use <code>Fiber.try()</code> to catch parsing errors.</p>
</div>
</article>
<footer class="page-footer">
<a href="dns.html" class="prev">dns</a>
<a href="base64.html" class="next">base64</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,295 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>sqlite - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html" class="active">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>sqlite</span>
</nav>
<article>
<h1>sqlite</h1>
<p>The <code>sqlite</code> module provides SQLite database functionality for persistent data storage.</p>
<pre><code>import "sqlite" for Sqlite</code></pre>
<h2>Sqlite Class</h2>
<div class="class-header">
<h3>Sqlite</h3>
<p>SQLite database connection</p>
</div>
<h3>Constructors</h3>
<div class="method-signature">
<span class="method-name">Sqlite.open</span>(<span class="param">path</span>) → <span class="type">Sqlite</span>
</div>
<p>Opens or creates an SQLite database file.</p>
<ul class="param-list">
<li><span class="param-name">path</span> <span class="param-type">(String)</span> - Path to the database file</li>
<li><span class="returns">Returns:</span> Database connection</li>
</ul>
<pre><code>var db = Sqlite.open("data.db")</code></pre>
<h3>Methods</h3>
<div class="method-signature">
<span class="method-name">execute</span>(<span class="param">sql</span>) → <span class="type">List</span>
</div>
<p>Executes an SQL statement and returns the results.</p>
<ul class="param-list">
<li><span class="param-name">sql</span> <span class="param-type">(String)</span> - SQL statement</li>
<li><span class="returns">Returns:</span> List of result rows (each row is a Map)</li>
</ul>
<pre><code>var rows = db.execute("SELECT * FROM users")
for (row in rows) {
System.print(row["name"])
}</code></pre>
<div class="method-signature">
<span class="method-name">execute</span>(<span class="param">sql</span>, <span class="param">params</span>) → <span class="type">List</span>
</div>
<p>Executes a parameterized SQL statement (prevents SQL injection).</p>
<ul class="param-list">
<li><span class="param-name">sql</span> <span class="param-type">(String)</span> - SQL with ? placeholders</li>
<li><span class="param-name">params</span> <span class="param-type">(List)</span> - Parameter values</li>
</ul>
<pre><code>var rows = db.execute("SELECT * FROM users WHERE age > ?", [18])</code></pre>
<div class="method-signature">
<span class="method-name">lastInsertId</span><span class="type">Num</span>
</div>
<p>Returns the row ID of the last INSERT operation.</p>
<div class="method-signature">
<span class="method-name">close</span>()
</div>
<p>Closes the database connection.</p>
<h2>Examples</h2>
<h3>Creating Tables</h3>
<pre><code>import "sqlite" for Sqlite
var db = Sqlite.open("app.db")
db.execute("
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT UNIQUE,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
")
db.close()</code></pre>
<h3>Inserting Data</h3>
<pre><code>import "sqlite" for Sqlite
var db = Sqlite.open("app.db")
db.execute("INSERT INTO users (name, email) VALUES (?, ?)", ["Alice", "alice@example.com"])
System.print("Inserted user with ID: %(db.lastInsertId)")
db.execute("INSERT INTO users (name, email) VALUES (?, ?)", ["Bob", "bob@example.com"])
db.close()</code></pre>
<h3>Querying Data</h3>
<pre><code>import "sqlite" for Sqlite
var db = Sqlite.open("app.db")
var users = db.execute("SELECT * FROM users ORDER BY name")
for (user in users) {
System.print("%(user["id"]): %(user["name"]) <%(user["email"])>")
}
var user = db.execute("SELECT * FROM users WHERE id = ?", [1])
if (user.count > 0) {
System.print("Found: %(user[0]["name"])")
}
db.close()</code></pre>
<h3>Updating Data</h3>
<pre><code>import "sqlite" for Sqlite
var db = Sqlite.open("app.db")
db.execute("UPDATE users SET email = ? WHERE id = ?", ["newemail@example.com", 1])
db.close()</code></pre>
<h3>Deleting Data</h3>
<pre><code>import "sqlite" for Sqlite
var db = Sqlite.open("app.db")
db.execute("DELETE FROM users WHERE id = ?", [2])
db.close()</code></pre>
<h3>Transactions</h3>
<pre><code>import "sqlite" for Sqlite
var db = Sqlite.open("app.db")
db.execute("BEGIN TRANSACTION")
var fiber = Fiber.new {
db.execute("INSERT INTO users (name, email) VALUES (?, ?)", ["Charlie", "charlie@example.com"])
db.execute("INSERT INTO users (name, email) VALUES (?, ?)", ["Diana", "diana@example.com"])
}
var error = fiber.try()
if (error) {
db.execute("ROLLBACK")
System.print("Error: %(error)")
} else {
db.execute("COMMIT")
System.print("Transaction committed")
}
db.close()</code></pre>
<div class="admonition tip">
<div class="admonition-title">Tip</div>
<p>Always use parameterized queries with <code>?</code> placeholders to prevent SQL injection attacks. Never concatenate user input directly into SQL strings.</p>
</div>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>Use <code>":memory:"</code> as the path for an in-memory database that does not persist to disk.</p>
</div>
</article>
<footer class="page-footer">
<a href="signal.html" class="prev">signal</a>
<a href="subprocess.html" class="next">subprocess</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,218 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>subprocess - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html" class="active">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>subprocess</span>
</nav>
<article>
<h1>subprocess</h1>
<p>The <code>subprocess</code> module allows running external commands and capturing their output.</p>
<pre><code>import "subprocess" for Subprocess</code></pre>
<h2>Subprocess Class</h2>
<div class="class-header">
<h3>Subprocess</h3>
<p>External process execution</p>
</div>
<h3>Static Methods</h3>
<div class="method-signature">
<span class="method-name">Subprocess.run</span>(<span class="param">command</span>) → <span class="type">Map</span>
</div>
<p>Runs a command and waits for it to complete.</p>
<ul class="param-list">
<li><span class="param-name">command</span> <span class="param-type">(List)</span> - Command and arguments as a list</li>
<li><span class="returns">Returns:</span> Map with "stdout", "stderr", and "exitCode"</li>
</ul>
<pre><code>var result = Subprocess.run(["ls", "-la"])
System.print("Exit code: %(result["exitCode"])")
System.print("Output: %(result["stdout"])")</code></pre>
<div class="method-signature">
<span class="method-name">Subprocess.run</span>(<span class="param">command</span>, <span class="param">input</span>) → <span class="type">Map</span>
</div>
<p>Runs a command with input data provided to stdin.</p>
<ul class="param-list">
<li><span class="param-name">command</span> <span class="param-type">(List)</span> - Command and arguments</li>
<li><span class="param-name">input</span> <span class="param-type">(String)</span> - Input to send to stdin</li>
</ul>
<pre><code>var result = Subprocess.run(["cat"], "Hello, World!")
System.print(result["stdout"]) // Hello, World!</code></pre>
<h2>Examples</h2>
<h3>Running Commands</h3>
<pre><code>import "subprocess" for Subprocess
var result = Subprocess.run(["echo", "Hello"])
System.print(result["stdout"]) // Hello
var files = Subprocess.run(["ls", "-la", "/tmp"])
System.print(files["stdout"])</code></pre>
<h3>Checking Exit Codes</h3>
<pre><code>import "subprocess" for Subprocess
var result = Subprocess.run(["grep", "pattern", "file.txt"])
if (result["exitCode"] == 0) {
System.print("Found: %(result["stdout"])")
} else {
System.print("Not found or error")
}</code></pre>
<h3>Processing Data</h3>
<pre><code>import "subprocess" for Subprocess
import "json" for Json
var result = Subprocess.run(["curl", "-s", "https://api.example.com/data"])
if (result["exitCode"] == 0) {
var data = Json.parse(result["stdout"])
System.print(data)
}</code></pre>
<h3>Piping Data</h3>
<pre><code>import "subprocess" for Subprocess
var input = "line1\nline2\nline3"
var result = Subprocess.run(["wc", "-l"], input)
System.print("Lines: %(result["stdout"].trim())")</code></pre>
<div class="admonition warning">
<div class="admonition-title">Warning</div>
<p>Commands are not executed through a shell. Use explicit command and argument lists, not shell command strings.</p>
</div>
</article>
<footer class="page-footer">
<a href="sqlite.html" class="prev">sqlite</a>
<a href="sysinfo.html" class="next">sysinfo</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,281 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>tls - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html" class="active">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>tls</span>
</nav>
<article>
<h1>tls</h1>
<p>The <code>tls</code> module provides SSL/TLS socket support for secure network connections. It uses OpenSSL for encryption and is used internally by the <code>http</code> module for HTTPS connections.</p>
<pre><code>import "tls" for TlsSocket</code></pre>
<div class="toc">
<h4>On This Page</h4>
<ul>
<li><a href="#tlssocket-class">TlsSocket Class</a></li>
<li><a href="#examples">Examples</a></li>
</ul>
</div>
<h2 id="tlssocket-class">TlsSocket Class</h2>
<div class="class-header">
<h3>TlsSocket</h3>
<p>SSL/TLS encrypted socket connection</p>
</div>
<h3>Static Methods</h3>
<div class="method-signature">
<span class="method-name">TlsSocket.connect</span>(<span class="param">host</span>, <span class="param">port</span>, <span class="param">hostname</span>) &#8594; <span class="type">TlsSocket</span>
</div>
<p>Establishes a TLS connection to a remote server.</p>
<ul class="param-list">
<li><span class="param-name">host</span> <span class="param-type">(String)</span> - IP address to connect to</li>
<li><span class="param-name">port</span> <span class="param-type">(Num)</span> - Port number (typically 443 for HTTPS)</li>
<li><span class="param-name">hostname</span> <span class="param-type">(String)</span> - Server hostname for SNI (Server Name Indication)</li>
<li><span class="returns">Returns:</span> Connected TlsSocket instance</li>
</ul>
<pre><code>var socket = TlsSocket.connect("93.184.216.34", 443, "example.com")</code></pre>
<h3>Methods</h3>
<div class="method-signature">
<span class="method-name">write</span>(<span class="param">text</span>)
</div>
<p>Writes data to the TLS connection. This is an async operation that blocks until the data is sent.</p>
<ul class="param-list">
<li><span class="param-name">text</span> <span class="param-type">(String)</span> - Data to send</li>
</ul>
<pre><code>socket.write("GET / HTTP/1.1\r\nHost: example.com\r\n\r\n")</code></pre>
<div class="method-signature">
<span class="method-name">read</span>() &#8594; <span class="type">String|null</span>
</div>
<p>Reads data from the TLS connection. Blocks until data is available. Returns null when the connection is closed.</p>
<ul class="param-list">
<li><span class="returns">Returns:</span> Data received as a string, or null if connection closed</li>
</ul>
<pre><code>var data = socket.read()
if (data != null) {
System.print(data)
}</code></pre>
<div class="method-signature">
<span class="method-name">close</span>()
</div>
<p>Closes the TLS connection and releases resources.</p>
<pre><code>socket.close()</code></pre>
<h2 id="examples">Examples</h2>
<h3>Basic HTTPS Request</h3>
<pre><code>import "tls" for TlsSocket
import "dns" for Dns
var host = "example.com"
var ip = Dns.lookup(host)
var socket = TlsSocket.connect(ip, 443, host)
socket.write("GET / HTTP/1.1\r\n")
socket.write("Host: %(host)\r\n")
socket.write("Connection: close\r\n")
socket.write("\r\n")
var response = ""
while (true) {
var chunk = socket.read()
if (chunk == null) break
response = response + chunk
}
socket.close()
System.print(response)</code></pre>
<h3>Reading Until Complete</h3>
<pre><code>import "tls" for TlsSocket
import "dns" for Dns
var host = "api.example.com"
var ip = Dns.lookup(host)
var socket = TlsSocket.connect(ip, 443, host)
socket.write("GET /data HTTP/1.1\r\n")
socket.write("Host: %(host)\r\n")
socket.write("Accept: application/json\r\n")
socket.write("Connection: close\r\n\r\n")
var buffer = ""
while (true) {
var data = socket.read()
if (data == null) break
buffer = buffer + data
}
socket.close()
var bodyStart = buffer.indexOf("\r\n\r\n")
if (bodyStart != -1) {
var body = buffer[bodyStart + 4..-1]
System.print("Response body: %(body)")
}</code></pre>
<h3>Using with DNS Resolution</h3>
<pre><code>import "tls" for TlsSocket
import "dns" for Dns
var hostname = "secure.example.com"
var ip = Dns.lookup(hostname, 4)
System.print("Connecting to %(ip)")
var socket = TlsSocket.connect(ip, 443, hostname)
socket.write("GET /secure-endpoint HTTP/1.1\r\nHost: %(hostname)\r\n\r\n")
var response = socket.read()
System.print(response)
socket.close()</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>The <code>hostname</code> parameter is used for SNI (Server Name Indication), which is required when connecting to servers that host multiple domains on the same IP address. It should match the domain name in the server's certificate.</p>
</div>
<div class="admonition tip">
<div class="admonition-title">Tip</div>
<p>For most use cases, consider using the higher-level <code>http</code> module which handles TLS connections, HTTP protocol details, and response parsing automatically.</p>
</div>
</article>
<footer class="page-footer">
<a href="timer.html" class="prev">timer</a>
<a href="udp.html" class="next">udp</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,255 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>uuid - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html" class="active">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>uuid</span>
</nav>
<article>
<h1>uuid</h1>
<p>The <code>uuid</code> module provides UUID (Universally Unique Identifier) generation and validation. It supports version 4 UUIDs which are randomly generated.</p>
<pre><code>import "uuid" for Uuid</code></pre>
<h2>Uuid Class</h2>
<div class="class-header">
<h3>Uuid</h3>
<p>UUID generation and validation</p>
</div>
<h3>Static Methods</h3>
<div class="method-signature">
<span class="method-name">Uuid.v4</span>() → <span class="type">String</span>
</div>
<p>Generates a new random version 4 UUID.</p>
<ul class="param-list">
<li><span class="returns">Returns:</span> A 36-character UUID string in the format <code>xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx</code></li>
</ul>
<pre><code>var id = Uuid.v4()
System.print(id) // e.g., "550e8400-e29b-41d4-a716-446655440000"</code></pre>
<div class="method-signature">
<span class="method-name">Uuid.isValid</span>(<span class="param">string</span>) → <span class="type">Bool</span>
</div>
<p>Checks if a string is a valid UUID format (any version).</p>
<ul class="param-list">
<li><span class="param-name">string</span> <span class="param-type">(String)</span> - The string to validate</li>
<li><span class="returns">Returns:</span> <code>true</code> if the string is a valid UUID format, <code>false</code> otherwise</li>
</ul>
<pre><code>System.print(Uuid.isValid("550e8400-e29b-41d4-a716-446655440000")) // true
System.print(Uuid.isValid("not-a-uuid")) // false
System.print(Uuid.isValid("550e8400e29b41d4a716446655440000")) // false (missing hyphens)</code></pre>
<div class="method-signature">
<span class="method-name">Uuid.isV4</span>(<span class="param">string</span>) → <span class="type">Bool</span>
</div>
<p>Checks if a string is a valid version 4 UUID.</p>
<ul class="param-list">
<li><span class="param-name">string</span> <span class="param-type">(String)</span> - The string to validate</li>
<li><span class="returns">Returns:</span> <code>true</code> if the string is a valid v4 UUID, <code>false</code> otherwise</li>
</ul>
<pre><code>var id = Uuid.v4()
System.print(Uuid.isV4(id)) // true
System.print(Uuid.isV4("550e8400-e29b-11d4-a716-446655440000")) // false (version 1)</code></pre>
<h2>UUID Format</h2>
<p>UUIDs are 128-bit identifiers represented as 32 hexadecimal characters separated by hyphens into five groups:</p>
<pre><code>xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
8 4 4 4 12 = 32 hex chars + 4 hyphens = 36 chars</code></pre>
<table>
<tr>
<th>Position</th>
<th>Description</th>
</tr>
<tr>
<td>M</td>
<td>Version number (4 for v4 UUIDs)</td>
</tr>
<tr>
<td>N</td>
<td>Variant (8, 9, a, or b for RFC 4122 UUIDs)</td>
</tr>
</table>
<h2>Examples</h2>
<h3>Generating Unique Identifiers</h3>
<pre><code>import "uuid" for Uuid
var userId = Uuid.v4()
var sessionId = Uuid.v4()
System.print("User ID: %(userId)")
System.print("Session ID: %(sessionId)")</code></pre>
<h3>Validating User Input</h3>
<pre><code>import "uuid" for Uuid
var input = "550e8400-e29b-41d4-a716-446655440000"
if (Uuid.isValid(input)) {
System.print("Valid UUID")
if (Uuid.isV4(input)) {
System.print("This is a v4 UUID")
}
} else {
System.print("Invalid UUID format")
}</code></pre>
<h3>Using with Database Records</h3>
<pre><code>import "uuid" for Uuid
class User {
construct new(name) {
_id = Uuid.v4()
_name = name
}
id { _id }
name { _name }
}
var user = User.new("Alice")
System.print("Created user %(user.name) with ID %(user.id)")</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>Version 4 UUIDs are generated using cryptographically secure random bytes from the <code>crypto</code> module. The probability of generating duplicate UUIDs is astronomically low.</p>
</div>
</article>
<footer class="page-footer">
<a href="udp.html" class="prev">udp</a>
<a href="wdantic.html" class="next">wdantic</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,254 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contributing - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="index.html" class="active">Overview</a></li>
<li><a href="module-overview.html">Module Architecture</a></li>
<li><a href="pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="c-backed-module.html">C-Backed Modules</a></li>
<li><a href="foreign-classes.html">Foreign Classes</a></li>
<li><a href="async-patterns.html">Async Patterns</a></li>
<li><a href="testing.html">Writing Tests</a></li>
<li><a href="documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<span>Contributing</span>
</nav>
<article>
<h1>Contributing</h1>
<p>This guide explains how to contribute new modules to Wren-CLI, write tests, and add documentation. Whether you are adding a pure-Wren module or implementing C-backed foreign methods, this section provides step-by-step instructions.</p>
<div class="toc">
<h4>In This Section</h4>
<ul>
<li><a href="module-overview.html">Module Architecture</a> - Project structure and artifact matrix</li>
<li><a href="pure-wren-module.html">Pure-Wren Modules</a> - Step-by-step for Wren-only modules</li>
<li><a href="c-backed-module.html">C-Backed Modules</a> - Implementing foreign methods in C</li>
<li><a href="foreign-classes.html">Foreign Classes</a> - Native resource management</li>
<li><a href="async-patterns.html">Async Patterns</a> - Scheduler/Fiber and libuv integration</li>
<li><a href="testing.html">Writing Tests</a> - Test structure and annotations</li>
<li><a href="documentation.html">Documentation</a> - Writing manual pages</li>
</ul>
</div>
<h2>Prerequisites</h2>
<p>Before contributing, ensure you have:</p>
<ul>
<li>A working build environment (see <a href="../getting-started/installation.html">Installation</a>)</li>
<li>Python 3 (for utility scripts)</li>
<li>Basic understanding of <a href="../language/index.html">Wren syntax</a></li>
<li>For C-backed modules: familiarity with C and the Wren embedding API</li>
</ul>
<h2>Module Types</h2>
<p>Wren-CLI supports two types of modules:</p>
<table>
<tr>
<th>Type</th>
<th>Description</th>
<th>Files Required</th>
</tr>
<tr>
<td>Pure-Wren</td>
<td>Modules written entirely in Wren. Examples: argparse, html, jinja, http, markdown, dataset, web, websocket, wdantic, uuid, tempfile</td>
<td><code>.wren</code>, <code>.wren.inc</code>, modules.c entry</td>
</tr>
<tr>
<td>C-Backed</td>
<td>Modules with foreign methods implemented in C. Examples: json, io, net, crypto, tls, sqlite, base64</td>
<td><code>.wren</code>, <code>.wren.inc</code>, <code>.c</code>, <code>.h</code>, modules.c entry, Makefile entry</td>
</tr>
</table>
<h2>Workflow Checklist</h2>
<h3>Pure-Wren Module</h3>
<ol>
<li>Create <code>src/module/&lt;name&gt;.wren</code></li>
<li>Generate <code>.wren.inc</code> with <code>python3 util/wren_to_c_string.py</code></li>
<li>Add <code>#include</code> and <code>MODULE</code> block in <code>src/cli/modules.c</code></li>
<li>Build with <code>make clean && make build</code></li>
<li>Create tests in <code>test/&lt;name&gt;/</code></li>
<li>Create example in <code>example/&lt;name&gt;_demo.wren</code></li>
<li>Create <code>manual/api/&lt;name&gt;.html</code></li>
<li>Run <code>make sync-manual</code></li>
<li>Verify with <code>python3 util/test.py &lt;name&gt;</code></li>
</ol>
<h3>C-Backed Module</h3>
<ol>
<li>All pure-Wren steps, plus:</li>
<li>Create <code>src/module/&lt;name&gt;.c</code> with foreign method implementations</li>
<li>Create <code>src/module/&lt;name&gt;.h</code> with function declarations</li>
<li>Add extern declarations in <code>modules.c</code></li>
<li>Add <code>CLASS</code>/<code>METHOD</code> registrations with correct signatures</li>
<li>Add <code>OBJECTS</code> and compilation rule to <code>projects/make/wren_cli.make</code></li>
</ol>
<h2>Build Commands</h2>
<pre><code>make build # Release build
make debug # Debug build
make clean # Clean artifacts
make tests # Build and run all tests
make sync-manual # Sync sidebar across manual pages</code></pre>
<h2>Directory Structure</h2>
<pre><code>src/
cli/
modules.c # Foreign function registry
vm.c # VM and module loading
module/
&lt;name&gt;.wren # Wren interface source
&lt;name&gt;.wren.inc # Generated C string literal
&lt;name&gt;.c # C implementation (if foreign methods)
&lt;name&gt;.h # C header (if foreign methods)
test/
&lt;name&gt;/
&lt;feature&gt;.wren # Test files with annotations
example/
&lt;name&gt;_demo.wren # Usage demonstrations
manual/
api/&lt;name&gt;.html # API documentation</code></pre>
<h2>Getting Help</h2>
<p>If you encounter issues while contributing:</p>
<ul>
<li>Review existing modules as reference implementations</li>
<li>Check the test files for expected behavior patterns</li>
<li>Consult the <a href="module-overview.html">Module Architecture</a> section for detailed artifact requirements</li>
</ul>
<h2>Next Steps</h2>
<p>Start with the <a href="module-overview.html">Module Architecture</a> section to understand the project structure, then proceed to the appropriate module guide based on your needs.</p>
</article>
<footer class="page-footer">
<a href="../howto/error-handling.html" class="prev">Error Handling</a>
<a href="module-overview.html" class="next">Module Architecture</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,727 +0,0 @@
/* retoor <retoor@molodetz.nl> */
:root {
--sidebar-bg: #343131;
--sidebar-text: #d9d9d9;
--sidebar-link: #b3b3b3;
--sidebar-link-hover: #ffffff;
--sidebar-active: #2980b9;
--primary: #2980b9;
--primary-dark: #1a5276;
--text: #404040;
--heading: #2c3e50;
--code-bg: #f4f4f4;
--code-border: #e1e4e5;
--border: #e1e4e5;
--sidebar-width: 280px;
--content-max-width: 900px;
--link: #2980b9;
--link-hover: #1a5276;
--warning-bg: #fff3cd;
--warning-border: #ffc107;
--note-bg: #e7f2fa;
--note-border: #6ab0de;
--tip-bg: #dff0d8;
--tip-border: #3c763d;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 16px;
scroll-behavior: smooth;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
line-height: 1.6;
color: var(--text);
background: #ffffff;
}
.container {
display: flex;
min-height: 100vh;
}
.sidebar {
position: fixed;
top: 0;
left: 0;
width: var(--sidebar-width);
height: 100vh;
background: var(--sidebar-bg);
color: var(--sidebar-text);
overflow-y: auto;
z-index: 100;
}
.sidebar-header {
padding: 20px;
background: rgba(0, 0, 0, 0.1);
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-header h1 {
font-size: 1.5rem;
font-weight: 700;
margin: 0;
}
.sidebar-header h1 a {
color: #ffffff;
text-decoration: none;
}
.sidebar-header .version {
font-size: 0.85rem;
color: var(--sidebar-link);
margin-top: 5px;
}
.sidebar-nav {
padding: 15px 0;
}
.sidebar-nav .section {
margin-bottom: 10px;
}
.sidebar-nav .section-title {
display: block;
padding: 8px 20px;
font-size: 0.85rem;
font-weight: 700;
text-transform: uppercase;
color: var(--sidebar-text);
letter-spacing: 0.05em;
}
.sidebar-nav ul {
list-style: none;
}
.sidebar-nav li a {
display: block;
padding: 6px 20px 6px 30px;
color: var(--sidebar-link);
text-decoration: none;
font-size: 0.9rem;
transition: color 0.15s, background 0.15s;
}
.sidebar-nav li a:hover {
color: var(--sidebar-link-hover);
background: rgba(255, 255, 255, 0.05);
}
.sidebar-nav li a.active {
color: var(--sidebar-active);
background: rgba(255, 255, 255, 0.05);
border-left: 3px solid var(--sidebar-active);
padding-left: 27px;
}
.sidebar-nav li.nested a {
padding-left: 45px;
font-size: 0.85rem;
}
.content {
flex: 1;
margin-left: var(--sidebar-width);
padding: 40px 50px;
max-width: calc(var(--content-max-width) + var(--sidebar-width) + 100px);
}
article {
max-width: var(--content-max-width);
}
h1, h2, h3, h4, h5, h6 {
color: var(--heading);
font-weight: 700;
line-height: 1.3;
margin-top: 1.5em;
margin-bottom: 0.5em;
}
h1 {
font-size: 2rem;
margin-top: 0;
padding-bottom: 0.3em;
border-bottom: 1px solid var(--border);
}
h2 {
font-size: 1.5rem;
margin-top: 2em;
}
h3 {
font-size: 1.25rem;
}
h4 {
font-size: 1.1rem;
}
p {
margin-bottom: 1em;
}
a {
color: var(--link);
text-decoration: none;
}
a:hover {
color: var(--link-hover);
text-decoration: underline;
}
code {
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Monaco, monospace;
font-size: 0.9em;
background: var(--code-bg);
padding: 2px 6px;
border-radius: 3px;
border: 1px solid var(--code-border);
}
pre {
background: var(--code-bg);
border: 1px solid var(--code-border);
border-radius: 4px;
padding: 15px 20px;
overflow-x: auto;
margin: 1em 0;
position: relative;
}
pre code {
background: none;
border: none;
padding: 0;
font-size: 0.875rem;
line-height: 1.5;
}
.code-block {
position: relative;
}
.code-block .copy-btn {
position: absolute;
top: 8px;
right: 8px;
padding: 4px 10px;
font-size: 0.75rem;
background: var(--primary);
color: #ffffff;
border: none;
border-radius: 3px;
cursor: pointer;
opacity: 0;
transition: opacity 0.2s;
}
.code-block:hover .copy-btn {
opacity: 1;
}
.copy-btn:hover {
background: var(--primary-dark);
}
.copy-btn.copied {
background: var(--tip-border);
}
.method-signature {
background: #f8f8f8;
border-left: 4px solid var(--primary);
padding: 12px 16px;
margin: 1em 0;
font-family: "SFMono-Regular", Consolas, monospace;
font-size: 0.9rem;
overflow-x: auto;
}
.method-signature .method-name {
color: var(--primary-dark);
font-weight: 600;
}
.method-signature .param {
color: #c0392b;
}
.method-signature .type {
color: #27ae60;
}
ul, ol {
margin: 1em 0;
padding-left: 2em;
}
li {
margin-bottom: 0.5em;
}
ul.param-list {
list-style: none;
padding-left: 0;
margin: 0.5em 0 1em;
}
ul.param-list li {
padding: 4px 0;
padding-left: 1.5em;
position: relative;
}
ul.param-list li::before {
content: "•";
position: absolute;
left: 0.5em;
color: var(--primary);
}
.param-name {
font-family: monospace;
background: var(--code-bg);
padding: 1px 5px;
border-radius: 2px;
}
.param-type {
color: #27ae60;
font-size: 0.9em;
}
.returns {
color: #8e44ad;
font-weight: 500;
}
table {
width: 100%;
border-collapse: collapse;
margin: 1em 0;
}
th, td {
padding: 10px 12px;
text-align: left;
border: 1px solid var(--border);
}
th {
background: var(--code-bg);
font-weight: 600;
}
tr:nth-child(even) {
background: #fafafa;
}
.admonition {
padding: 15px 20px;
margin: 1.5em 0;
border-radius: 4px;
border-left: 4px solid;
}
.admonition-title {
font-weight: 700;
margin-bottom: 0.5em;
}
.admonition.note {
background: var(--note-bg);
border-color: var(--note-border);
}
.admonition.warning {
background: var(--warning-bg);
border-color: var(--warning-border);
}
.admonition.tip {
background: var(--tip-bg);
border-color: var(--tip-border);
}
.page-footer {
display: flex;
justify-content: space-between;
margin-top: 3em;
padding-top: 1.5em;
border-top: 1px solid var(--border);
}
.page-footer a {
display: inline-flex;
align-items: center;
padding: 8px 16px;
background: var(--code-bg);
border-radius: 4px;
font-weight: 500;
}
.page-footer a:hover {
background: var(--border);
text-decoration: none;
}
.page-footer .prev::before {
content: "← ";
}
.page-footer .next::after {
content: " →";
}
.breadcrumb {
margin-bottom: 1.5em;
font-size: 0.9rem;
color: #666;
}
.breadcrumb a {
color: #666;
}
.breadcrumb a:hover {
color: var(--primary);
}
.breadcrumb .separator {
margin: 0 0.5em;
}
.mobile-menu-toggle {
display: none;
position: fixed;
top: 15px;
left: 15px;
z-index: 200;
background: var(--sidebar-bg);
color: #ffffff;
border: none;
padding: 10px 15px;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
}
.hero {
text-align: center;
padding: 60px 20px;
background: linear-gradient(135deg, var(--heading) 0%, var(--primary) 100%);
color: #ffffff;
margin: -40px -50px 40px;
border-radius: 0 0 8px 8px;
}
.hero h1 {
color: #ffffff;
border: none;
font-size: 2.5rem;
margin-bottom: 0.5em;
}
.hero p {
font-size: 1.2rem;
opacity: 0.9;
max-width: 600px;
margin: 0 auto 1.5em;
}
.hero-buttons {
display: flex;
gap: 15px;
justify-content: center;
flex-wrap: wrap;
}
.hero-buttons a {
padding: 12px 24px;
border-radius: 4px;
font-weight: 600;
text-decoration: none;
transition: transform 0.15s, box-shadow 0.15s;
}
.hero-buttons .primary-btn {
background: #ffffff;
color: var(--primary);
}
.hero-buttons .secondary-btn {
background: rgba(255, 255, 255, 0.15);
color: #ffffff;
border: 1px solid rgba(255, 255, 255, 0.3);
}
.hero-buttons a:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
margin: 2em 0;
}
.card {
background: #ffffff;
border: 1px solid var(--border);
border-radius: 8px;
padding: 20px;
transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
transform: translateY(-2px);
}
.card h3 {
margin-top: 0;
margin-bottom: 0.5em;
}
.card h3 a {
color: var(--heading);
}
.card p {
margin: 0;
color: #666;
font-size: 0.95rem;
}
.module-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 15px;
margin: 1.5em 0;
}
.module-card {
display: block;
padding: 15px;
background: var(--code-bg);
border: 1px solid var(--border);
border-radius: 6px;
text-align: center;
font-weight: 500;
color: var(--heading);
transition: all 0.2s;
}
.module-card:hover {
background: var(--primary);
color: #ffffff;
text-decoration: none;
border-color: var(--primary);
}
.toc {
background: var(--code-bg);
border: 1px solid var(--border);
border-radius: 4px;
padding: 20px;
margin: 1.5em 0;
}
.toc h4 {
margin: 0 0 10px;
font-size: 1rem;
}
.toc ul {
margin: 0;
padding-left: 1.5em;
}
.toc li {
margin-bottom: 0.3em;
}
.api-section {
margin: 2em 0;
padding: 1.5em;
background: #fafafa;
border-radius: 8px;
border: 1px solid var(--border);
}
.api-section h3 {
margin-top: 0;
color: var(--primary);
}
.class-header {
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
padding: 20px;
border-radius: 8px;
margin: 1.5em 0 1em;
border-left: 4px solid var(--primary);
}
.class-header h3 {
margin: 0;
color: var(--heading);
}
.class-header p {
margin: 0.5em 0 0;
color: #666;
}
@media (max-width: 900px) {
.sidebar {
transform: translateX(-100%);
transition: transform 0.3s;
}
.sidebar.open {
transform: translateX(0);
}
.mobile-menu-toggle {
display: block;
}
.content {
margin-left: 0;
padding: 70px 20px 40px;
}
.hero {
margin: -70px -20px 30px;
padding: 80px 20px 40px;
}
.hero h1 {
font-size: 1.8rem;
}
h1 {
font-size: 1.6rem;
}
h2 {
font-size: 1.3rem;
}
pre {
padding: 12px;
}
.page-footer {
flex-direction: column;
gap: 10px;
}
.page-footer a {
text-align: center;
}
}
.sidebar-overlay {
display: none;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 50;
}
.sidebar-overlay.visible {
display: block;
}
.search-box {
padding: 15px 20px;
}
.search-box input {
width: 100%;
padding: 8px 12px;
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 4px;
background: rgba(255, 255, 255, 0.1);
color: #ffffff;
font-size: 0.9rem;
}
.search-box input::placeholder {
color: rgba(255, 255, 255, 0.5);
}
.search-box input:focus {
outline: none;
border-color: var(--primary);
background: rgba(255, 255, 255, 0.15);
}
.example-output {
background: #1e1e1e;
color: #d4d4d4;
padding: 15px 20px;
border-radius: 4px;
margin: 1em 0;
font-family: monospace;
font-size: 0.875rem;
}
.example-output::before {
content: "Output:";
display: block;
color: #888;
margin-bottom: 8px;
font-size: 0.8rem;
}
.deprecated {
opacity: 0.7;
text-decoration: line-through;
}
.badge {
display: inline-block;
padding: 2px 8px;
font-size: 0.75rem;
font-weight: 600;
border-radius: 3px;
margin-left: 8px;
vertical-align: middle;
}
.badge-new {
background: #27ae60;
color: #ffffff;
}
.badge-experimental {
background: #f39c12;
color: #ffffff;
}
.badge-async {
background: #9b59b6;
color: #ffffff;
}

View File

@ -1,331 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>First Script - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="installation.html">Installation</a></li>
<li><a href="first-script.html" class="active">First Script</a></li>
<li><a href="repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Getting Started</a>
<span class="separator">/</span>
<span>First Script</span>
</nav>
<article>
<h1>First Script</h1>
<p>This guide walks you through creating and running your first Wren script. You will learn the basics of printing output, using variables, and importing modules.</p>
<h2>Hello World</h2>
<p>Create a file named <code>hello.wren</code> with the following content:</p>
<pre><code>System.print("Hello, World!")</code></pre>
<p>Run it:</p>
<pre><code>bin/wren_cli hello.wren</code></pre>
<div class="example-output">Hello, World!</div>
<p>The <code>System.print</code> method outputs text to the console followed by a newline.</p>
<h2>Variables and Types</h2>
<p>Wren is dynamically typed. Use <code>var</code> to declare variables:</p>
<pre><code>var name = "Wren"
var version = 0.4
var features = ["fast", "small", "class-based"]
var active = true
System.print("Language: %(name)")
System.print("Version: %(version)")
System.print("Features: %(features)")
System.print("Active: %(active)")</code></pre>
<div class="example-output">Language: Wren
Version: 0.4
Features: [fast, small, class-based]
Active: true</div>
<p>The <code>%(expression)</code> syntax is string interpolation. It evaluates the expression and inserts the result into the string.</p>
<h2>Working with Lists and Maps</h2>
<pre><code>var numbers = [1, 2, 3, 4, 5]
System.print("Count: %(numbers.count)")
System.print("First: %(numbers[0])")
System.print("Last: %(numbers[-1])")
var person = {
"name": "Alice",
"age": 30,
"city": "Amsterdam"
}
System.print("Name: %(person["name"])")</code></pre>
<div class="example-output">Count: 5
First: 1
Last: 5
Name: Alice</div>
<h2>Control Flow</h2>
<pre><code>var score = 85
if (score >= 90) {
System.print("Grade: A")
} else if (score >= 80) {
System.print("Grade: B")
} else {
System.print("Grade: C")
}
for (i in 1..5) {
System.print("Count: %(i)")
}</code></pre>
<div class="example-output">Grade: B
Count: 1
Count: 2
Count: 3
Count: 4
Count: 5</div>
<h2>Functions</h2>
<p>Functions in Wren are created using block syntax:</p>
<pre><code>var greet = Fn.new { |name|
return "Hello, %(name)!"
}
System.print(greet.call("World"))
var add = Fn.new { |a, b| a + b }
System.print(add.call(3, 4))</code></pre>
<div class="example-output">Hello, World!
7</div>
<h2>Classes</h2>
<pre><code>class Person {
construct new(name, age) {
_name = name
_age = age
}
name { _name }
age { _age }
greet() {
System.print("Hello, I'm %(_name)")
}
}
var alice = Person.new("Alice", 30)
alice.greet()
System.print("Age: %(alice.age)")</code></pre>
<div class="example-output">Hello, I'm Alice
Age: 30</div>
<h2>Using Modules</h2>
<p>Wren-CLI provides many built-in modules. Import them to use their functionality:</p>
<pre><code>import "io" for File
var content = File.read("hello.wren")
System.print("File contents:")
System.print(content)</code></pre>
<h3>Making HTTP Requests</h3>
<pre><code>import "http" for Http
import "json" for Json
var response = Http.get("https://httpbin.org/get")
System.print("Status: %(response.status)")
var data = Json.parse(response.body)
System.print("Origin: %(data["origin"])")</code></pre>
<h3>Working with JSON</h3>
<pre><code>import "json" for Json
var data = {
"name": "Wren",
"version": 0.4,
"features": ["fast", "small"]
}
var jsonString = Json.stringify(data)
System.print(jsonString)
var parsed = Json.parse(jsonString)
System.print("Name: %(parsed["name"])")</code></pre>
<h2>Error Handling</h2>
<p>Use <code>Fiber.try</code> to catch runtime errors:</p>
<pre><code>var fiber = Fiber.new {
var x = 1 / 0
}
var error = fiber.try()
if (error) {
System.print("Error: %(error)")
}</code></pre>
<h2>Script Arguments</h2>
<p>Access command-line arguments via <code>Process.arguments</code>:</p>
<pre><code>import "os" for Process
System.print("Script arguments:")
for (arg in Process.arguments) {
System.print(" %(arg)")
}</code></pre>
<p>Run with arguments:</p>
<pre><code>bin/wren_cli script.wren arg1 arg2 arg3</code></pre>
<h2>Exit Codes</h2>
<p>Wren-CLI uses these exit codes:</p>
<table>
<tr>
<th>Code</th>
<th>Meaning</th>
</tr>
<tr>
<td>0</td>
<td>Success</td>
</tr>
<tr>
<td>65</td>
<td>Compile error (syntax error)</td>
</tr>
<tr>
<td>70</td>
<td>Runtime error</td>
</tr>
</table>
<h2>Next Steps</h2>
<ul>
<li><a href="repl.html">Using the REPL</a> - Interactive experimentation</li>
<li><a href="../language/index.html">Language Reference</a> - Deep dive into Wren syntax</li>
<li><a href="../tutorials/index.html">Tutorials</a> - Build real applications</li>
</ul>
</article>
<footer class="page-footer">
<a href="installation.html" class="prev">Installation</a>
<a href="repl.html" class="next">Using the REPL</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,230 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Getting Started - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="index.html" class="active">Overview</a></li>
<li><a href="installation.html">Installation</a></li>
<li><a href="first-script.html">First Script</a></li>
<li><a href="repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<span>Getting Started</span>
</nav>
<article>
<h1>Getting Started</h1>
<p>Welcome to Wren-CLI, a command-line interface for the Wren programming language extended with powerful modules for networking, file I/O, databases, and more.</p>
<div class="toc">
<h4>In This Section</h4>
<ul>
<li><a href="installation.html">Installation</a> - Build from source on Linux, macOS, or FreeBSD</li>
<li><a href="first-script.html">First Script</a> - Write and run your first Wren program</li>
<li><a href="repl.html">Using the REPL</a> - Interactive experimentation</li>
</ul>
</div>
<h2>What is Wren?</h2>
<p>Wren is a small, fast, class-based scripting language. It has a familiar syntax, first-class functions, and a fiber-based concurrency model. Wren-CLI extends the core language with modules for:</p>
<ul>
<li>HTTP and WebSocket networking</li>
<li>File and directory operations</li>
<li>SQLite database access</li>
<li>JSON and regex processing</li>
<li>Template rendering (Jinja2-compatible)</li>
<li>Cryptographic operations</li>
<li>Process and signal handling</li>
</ul>
<h2>Quick Start</h2>
<p>If you want to dive right in, here is the fastest path to running your first script:</p>
<h3>1. Build</h3>
<pre><code>git clone https://github.com/wren-lang/wren-cli.git
cd wren-cli
cd projects/make && make</code></pre>
<h3>2. Create a Script</h3>
<p>Create a file named <code>hello.wren</code>:</p>
<pre><code>System.print("Hello, Wren!")</code></pre>
<h3>3. Run</h3>
<pre><code>bin/wren_cli hello.wren</code></pre>
<div class="example-output">Hello, Wren!</div>
<h2>Key Concepts</h2>
<p>Before diving deeper, understand these fundamental Wren concepts:</p>
<h3>Everything is an Object</h3>
<p>In Wren, everything is an object, including numbers, strings, and functions. Every object is an instance of a class.</p>
<pre><code>var name = "Wren"
System.print(name.count) // 4
System.print(name.bytes[0]) // 87 (ASCII for 'W')</code></pre>
<h3>Fibers for Concurrency</h3>
<p>Wren uses fibers (cooperative threads) for concurrency. The scheduler module manages async operations.</p>
<pre><code>import "timer" for Timer
Timer.sleep(1000) // Pauses for 1 second
System.print("Done waiting")</code></pre>
<h3>Module System</h3>
<p>Functionality is organized into modules that you import as needed:</p>
<pre><code>import "http" for Http
import "json" for Json
var response = Http.get("https://api.example.com/data")
var data = Json.parse(response.body)</code></pre>
<h2>System Requirements</h2>
<table>
<tr>
<th>Platform</th>
<th>Requirements</th>
</tr>
<tr>
<td>Linux</td>
<td>GCC, Make, OpenSSL development libraries</td>
</tr>
<tr>
<td>macOS</td>
<td>Xcode Command Line Tools, OpenSSL (via Homebrew)</td>
</tr>
<tr>
<td>FreeBSD</td>
<td>GCC or Clang, gmake, OpenSSL</td>
</tr>
</table>
<h2>Next Steps</h2>
<p>Continue with the following sections to learn more:</p>
<ul>
<li><a href="installation.html">Installation</a> - Detailed build instructions for all platforms</li>
<li><a href="first-script.html">First Script</a> - A more detailed walkthrough of your first program</li>
<li><a href="../language/index.html">Language Reference</a> - Learn the Wren language syntax</li>
<li><a href="../api/index.html">API Reference</a> - Explore all available modules</li>
</ul>
</article>
<footer class="page-footer">
<a href="../index.html" class="prev">Home</a>
<a href="installation.html" class="next">Installation</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,288 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Installation - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="installation.html" class="active">Installation</a></li>
<li><a href="first-script.html">First Script</a></li>
<li><a href="repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Getting Started</a>
<span class="separator">/</span>
<span>Installation</span>
</nav>
<article>
<h1>Installation</h1>
<p>Wren-CLI must be built from source. This page covers the build process for Linux, macOS, and FreeBSD.</p>
<div class="toc">
<h4>On This Page</h4>
<ul>
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#linux">Building on Linux</a></li>
<li><a href="#macos">Building on macOS</a></li>
<li><a href="#freebsd">Building on FreeBSD</a></li>
<li><a href="#configurations">Build Configurations</a></li>
<li><a href="#verification">Verifying Installation</a></li>
</ul>
</div>
<h2 id="prerequisites">Prerequisites</h2>
<p>All platforms require:</p>
<ul>
<li>Git</li>
<li>C compiler (GCC or Clang)</li>
<li>Make</li>
<li>OpenSSL development libraries (for TLS/HTTPS support)</li>
<li>Python 3 (for running tests)</li>
</ul>
<h2 id="linux">Building on Linux</h2>
<h3>Install Dependencies</h3>
<p>On Debian/Ubuntu:</p>
<pre><code>sudo apt-get update
sudo apt-get install build-essential libssl-dev git python3</code></pre>
<p>On Fedora/RHEL:</p>
<pre><code>sudo dnf install gcc make openssl-devel git python3</code></pre>
<p>On Arch Linux:</p>
<pre><code>sudo pacman -S base-devel openssl git python</code></pre>
<h3>Build</h3>
<pre><code>git clone https://github.com/wren-lang/wren-cli.git
cd wren-cli
make build</code></pre>
<p>The binary will be created at <code>bin/wren_cli</code>.</p>
<h3>Install System-Wide (Optional)</h3>
<pre><code>sudo cp bin/wren_cli /usr/local/bin/wren</code></pre>
<h2 id="macos">Building on macOS</h2>
<h3>Install Dependencies</h3>
<p>Install Xcode Command Line Tools:</p>
<pre><code>xcode-select --install</code></pre>
<p>Install OpenSSL via Homebrew:</p>
<pre><code>brew install openssl</code></pre>
<h3>Build</h3>
<pre><code>git clone https://github.com/wren-lang/wren-cli.git
cd wren-cli
cd projects/make.mac && make</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>If OpenSSL is not found, you may need to set the library path:</p>
<pre><code>export LDFLAGS="-L/opt/homebrew/opt/openssl/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl/include"</code></pre>
</div>
<h2 id="freebsd">Building on FreeBSD</h2>
<h3>Install Dependencies</h3>
<pre><code>sudo pkg install gmake git python3</code></pre>
<h3>Build</h3>
<pre><code>git clone https://github.com/wren-lang/wren-cli.git
cd wren-cli
cd projects/make.bsd && gmake</code></pre>
<h2 id="configurations">Build Configurations</h2>
<p>Several build configurations are available:</p>
<table>
<tr>
<th>Configuration</th>
<th>Description</th>
</tr>
<tr>
<td><code>release_64bit</code></td>
<td>Default optimized 64-bit build</td>
</tr>
<tr>
<td><code>release_32bit</code></td>
<td>Optimized 32-bit build</td>
</tr>
<tr>
<td><code>debug_64bit</code></td>
<td>Debug build with symbols</td>
</tr>
<tr>
<td><code>debug_32bit</code></td>
<td>32-bit debug build</td>
</tr>
<tr>
<td><code>release_64bit-no-nan-tagging</code></td>
<td>Without NaN tagging optimization</td>
</tr>
<tr>
<td><code>debug_64bit-no-nan-tagging</code></td>
<td>Debug without NaN tagging</td>
</tr>
</table>
<p>To use a specific configuration:</p>
<pre><code>make config=debug_64bit</code></pre>
<p>Debug builds output to <code>bin/wren_cli_d</code>.</p>
<h2 id="verification">Verifying Installation</h2>
<p>Verify the build was successful:</p>
<pre><code>bin/wren_cli --version</code></pre>
<p>Run the test suite:</p>
<pre><code>make tests</code></pre>
<p>Start the REPL:</p>
<pre><code>bin/wren_cli</code></pre>
<div class="example-output">> </div>
<p>Type <code>System.print("Hello")</code> and press Enter to verify the REPL works.</p>
<h2>Troubleshooting</h2>
<h3>OpenSSL Not Found</h3>
<p>If you see errors about missing OpenSSL headers:</p>
<ul>
<li>Verify OpenSSL development packages are installed</li>
<li>On macOS, ensure Homebrew OpenSSL path is in your environment</li>
</ul>
<h3>Build Errors</h3>
<p>Try cleaning and rebuilding:</p>
<pre><code>make clean
make build</code></pre>
<h3>Test Failures</h3>
<p>Run a specific test module to isolate issues:</p>
<pre><code>python3 util/test.py json</code></pre>
</article>
<footer class="page-footer">
<a href="index.html" class="prev">Overview</a>
<a href="first-script.html" class="next">First Script</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,279 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Using the REPL - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="installation.html">Installation</a></li>
<li><a href="first-script.html">First Script</a></li>
<li><a href="repl.html" class="active">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Getting Started</a>
<span class="separator">/</span>
<span>Using the REPL</span>
</nav>
<article>
<h1>Using the REPL</h1>
<p>The REPL (Read-Eval-Print Loop) is an interactive environment for experimenting with Wren code. It is useful for testing ideas, exploring APIs, and learning the language.</p>
<h2>Starting the REPL</h2>
<p>Run <code>wren_cli</code> without arguments to start the REPL:</p>
<pre><code>bin/wren_cli</code></pre>
<p>You will see a prompt:</p>
<div class="example-output">> </div>
<h2>Basic Usage</h2>
<p>Type expressions and press Enter to evaluate them:</p>
<pre><code>> 1 + 2
3
> "hello".count
5
> [1, 2, 3].map { |x| x * 2 }
[2, 4, 6]</code></pre>
<h2>Multi-line Input</h2>
<p>The REPL automatically detects incomplete expressions and waits for more input:</p>
<pre><code>> class Person {
| construct new(name) {
| _name = name
| }
| name { _name }
| }
null
> var p = Person.new("Alice")
null
> p.name
Alice</code></pre>
<p>The <code>|</code> prompt indicates the REPL is waiting for more input.</p>
<h2>Importing Modules</h2>
<p>Modules can be imported in the REPL just like in scripts:</p>
<pre><code>> import "json" for Json
null
> Json.stringify({"name": "Wren"})
{"name":"Wren"}
> import "math" for Math
null
> Math.sqrt(16)
4</code></pre>
<h2>Variables Persist</h2>
<p>Variables defined in the REPL persist across lines:</p>
<pre><code>> var x = 10
null
> var y = 20
null
> x + y
30</code></pre>
<h2>Examining Values</h2>
<p>Use <code>System.print</code> for formatted output:</p>
<pre><code>> var data = {"name": "Wren", "version": 0.4}
null
> System.print(data)
{name: Wren, version: 0.4}</code></pre>
<p>Check the type of a value:</p>
<pre><code>> 42.type
Num
> "hello".type
String
> [1, 2, 3].type
List</code></pre>
<h2>Exploring Classes</h2>
<p>Examine what methods a class provides:</p>
<pre><code>> String
String
> "test".bytes
[116, 101, 115, 116]
> "test".codePoints.toList
[116, 101, 115, 116]</code></pre>
<h2>Error Handling</h2>
<p>Errors are displayed but do not crash the REPL:</p>
<pre><code>> 1 / 0
infinity
> "test"[10]
Subscript out of bounds.
> undefined_variable
[repl line 1] Error at 'undefined_variable': Variable is used but not defined.</code></pre>
<p>You can continue using the REPL after errors.</p>
<h2>REPL Tips</h2>
<h3>Quick Testing</h3>
<p>Use the REPL to quickly test regular expressions:</p>
<pre><code>> import "regex" for Regex
null
> Regex.new("\\d+").test("abc123")
true
> Regex.new("\\d+").match("abc123def").text
123</code></pre>
<h3>Exploring APIs</h3>
<p>Test module functionality before using it in scripts:</p>
<pre><code>> import "base64" for Base64
null
> Base64.encode("Hello, World!")
SGVsbG8sIFdvcmxkIQ==
> Base64.decode("SGVsbG8sIFdvcmxkIQ==")
Hello, World!</code></pre>
<h3>Date and Time</h3>
<pre><code>> import "datetime" for DateTime
null
> DateTime.now
2024-01-15T10:30:45
> DateTime.now.year
2024</code></pre>
<h2>Exiting the REPL</h2>
<p>Exit the REPL by pressing <code>Ctrl+D</code> (Unix) or <code>Ctrl+Z</code> followed by Enter (Windows).</p>
<h2>Limitations</h2>
<ul>
<li>No command history navigation (arrow keys)</li>
<li>No tab completion</li>
<li>No line editing beyond basic backspace</li>
<li>Cannot redefine classes once defined</li>
</ul>
<div class="admonition tip">
<div class="admonition-title">Tip</div>
<p>For complex experimentation, write code in a file and run it with <code>wren_cli script.wren</code>. The REPL is best for quick tests and exploration.</p>
</div>
<h2>Next Steps</h2>
<ul>
<li><a href="../language/index.html">Language Reference</a> - Learn Wren syntax in detail</li>
<li><a href="../api/index.html">API Reference</a> - Explore available modules</li>
<li><a href="../tutorials/index.html">Tutorials</a> - Build real applications</li>
</ul>
</article>
<footer class="page-footer">
<a href="first-script.html" class="prev">First Script</a>
<a href="../language/index.html" class="next">Language Reference</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,362 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Making HTTP Requests - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="index.html">How-To List</a></li>
<li><a href="http-requests.html" class="active">HTTP Requests</a></li>
<li><a href="json-parsing.html">JSON Parsing</a></li>
<li><a href="regex-patterns.html">Regex Patterns</a></li>
<li><a href="file-operations.html">File Operations</a></li>
<li><a href="async-operations.html">Async Operations</a></li>
<li><a href="error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">How-To Guides</a>
<span class="separator">/</span>
<span>HTTP Requests</span>
</nav>
<article>
<h1>Making HTTP Requests</h1>
<h2>Basic GET Request</h2>
<pre><code>import "http" for Http
var response = Http.get("https://api.example.com/data")
System.print(response.body)</code></pre>
<h2>GET Request with JSON Response</h2>
<pre><code>import "http" for Http
var response = Http.get("https://jsonplaceholder.typicode.com/posts/1")
var data = response.json
System.print("Title: %(data["title"])")</code></pre>
<h2>GET Request with Headers</h2>
<pre><code>import "http" for Http
var response = Http.get("https://api.example.com/data", {
"Accept": "application/json",
"User-Agent": "Wren-CLI/1.0"
})
System.print(response.body)</code></pre>
<h2>POST Request with JSON Body</h2>
<pre><code>import "http" for Http
import "json" for Json
var data = {
"name": "John Doe",
"email": "john@example.com"
}
var response = Http.post(
"https://api.example.com/users",
Json.stringify(data),
{"Content-Type": "application/json"}
)
System.print("Status: %(response.statusCode)")
System.print("Created: %(response.json)")</code></pre>
<h2>PUT Request</h2>
<pre><code>import "http" for Http
import "json" for Json
var data = {
"id": 1,
"name": "Jane Doe",
"email": "jane@example.com"
}
var response = Http.put(
"https://api.example.com/users/1",
Json.stringify(data),
{"Content-Type": "application/json"}
)
System.print("Updated: %(response.statusCode == 200)")</code></pre>
<h2>DELETE Request</h2>
<pre><code>import "http" for Http
var response = Http.delete("https://api.example.com/users/1")
System.print("Deleted: %(response.statusCode == 204)")</code></pre>
<h2>PATCH Request</h2>
<pre><code>import "http" for Http
import "json" for Json
var response = Http.patch(
"https://api.example.com/users/1",
Json.stringify({"email": "newemail@example.com"}),
{"Content-Type": "application/json"}
)
System.print("Patched: %(response.statusCode)")</code></pre>
<h2>Bearer Token Authentication</h2>
<pre><code>import "http" for Http
var token = "your-api-token"
var response = Http.get("https://api.example.com/protected", {
"Authorization": "Bearer %(token)"
})
System.print(response.json)</code></pre>
<h2>Basic Authentication</h2>
<pre><code>import "http" for Http
import "base64" for Base64
var username = "user"
var password = "pass"
var credentials = Base64.encode("%(username):%(password)")
var response = Http.get("https://api.example.com/protected", {
"Authorization": "Basic %(credentials)"
})
System.print(response.body)</code></pre>
<h2>API Key Authentication</h2>
<pre><code>import "http" for Http
var response = Http.get("https://api.example.com/data", {
"X-API-Key": "your-api-key"
})
System.print(response.body)</code></pre>
<h2>Check Response Status</h2>
<pre><code>import "http" for Http
var response = Http.get("https://api.example.com/data")
if (response.statusCode == 200) {
System.print("Success: %(response.json)")
} else if (response.statusCode == 404) {
System.print("Not found")
} else if (response.statusCode >= 500) {
System.print("Server error: %(response.statusCode)")
} else {
System.print("Error: %(response.statusCode)")
}</code></pre>
<h2>Access Response Headers</h2>
<pre><code>import "http" for Http
var response = Http.get("https://api.example.com/data")
System.print("Content-Type: %(response.headers["content-type"])")
System.print("All headers: %(response.headers)")</code></pre>
<h2>URL Query Parameters</h2>
<pre><code>import "http" for Http
var response = Http.get("https://api.example.com/search?q=wren&limit=10")
System.print(response.json)</code></pre>
<h2>Form URL Encoded POST</h2>
<pre><code>import "http" for Http
var body = "username=john&password=secret"
var response = Http.post(
"https://api.example.com/login",
body,
{"Content-Type": "application/x-www-form-urlencoded"}
)
System.print(response.json)</code></pre>
<h2>Download File</h2>
<pre><code>import "http" for Http
import "io" for File
var response = Http.get("https://example.com/file.txt")
if (response.statusCode == 200) {
File.write("downloaded.txt", response.body)
System.print("File downloaded!")
}</code></pre>
<h2>HTTPS Request</h2>
<pre><code>import "http" for Http
var response = Http.get("https://secure.example.com/api")
System.print(response.body)</code></pre>
<h2>Error Handling</h2>
<pre><code>import "http" for Http
var fiber = Fiber.new {
return Http.get("https://api.example.com/data")
}
var response = fiber.try()
if (fiber.error) {
System.print("Request failed: %(fiber.error)")
} else if (response.statusCode >= 400) {
System.print("HTTP error: %(response.statusCode)")
} else {
System.print("Success: %(response.json)")
}</code></pre>
<h2>Retry on Failure</h2>
<pre><code>import "http" for Http
import "timer" for Timer
var fetchWithRetry = Fn.new { |url, maxRetries|
var attempt = 0
while (attempt < maxRetries) {
var fiber = Fiber.new { Http.get(url) }
var response = fiber.try()
if (!fiber.error && response.statusCode == 200) {
return response
}
attempt = attempt + 1
if (attempt < maxRetries) {
Timer.sleep(1000 * attempt)
}
}
return null
}
var response = fetchWithRetry.call("https://api.example.com/data", 3)
if (response) {
System.print(response.json)
} else {
System.print("Failed after 3 retries")
}</code></pre>
<div class="admonition tip">
<div class="admonition-title">See Also</div>
<p>For a complete API client example, see the <a href="../tutorials/http-client.html">HTTP Client Tutorial</a>. For full API documentation, see the <a href="../api/http.html">HTTP module reference</a>.</p>
</div>
</article>
<footer class="page-footer">
<a href="index.html" class="prev">How-To List</a>
<a href="json-parsing.html" class="next">JSON Parsing</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,236 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>How-To Guides - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="index.html" class="active">How-To List</a></li>
<li><a href="http-requests.html">HTTP Requests</a></li>
<li><a href="json-parsing.html">JSON Parsing</a></li>
<li><a href="regex-patterns.html">Regex Patterns</a></li>
<li><a href="file-operations.html">File Operations</a></li>
<li><a href="async-operations.html">Async Operations</a></li>
<li><a href="error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<span>How-To Guides</span>
</nav>
<article>
<h1>How-To Guides</h1>
<p>Quick, focused guides that show you how to accomplish specific tasks. Each guide provides working code examples you can copy and adapt for your projects.</p>
<div class="card-grid">
<div class="card">
<h3><a href="http-requests.html">Making HTTP Requests</a></h3>
<p>GET, POST, PUT, DELETE requests with headers, authentication, and error handling.</p>
<div class="card-meta">
<span class="tag">http</span>
</div>
</div>
<div class="card">
<h3><a href="json-parsing.html">Working with JSON</a></h3>
<p>Parse JSON strings, access nested data, create JSON output, and handle errors.</p>
<div class="card-meta">
<span class="tag">json</span>
</div>
</div>
<div class="card">
<h3><a href="regex-patterns.html">Using Regular Expressions</a></h3>
<p>Match, search, replace, and split text with regex patterns.</p>
<div class="card-meta">
<span class="tag">regex</span>
</div>
</div>
<div class="card">
<h3><a href="file-operations.html">File Operations</a></h3>
<p>Read, write, copy, and delete files. Work with directories and paths.</p>
<div class="card-meta">
<span class="tag">io</span>
</div>
</div>
<div class="card">
<h3><a href="async-operations.html">Async Programming</a></h3>
<p>Use fibers for concurrent operations, parallel requests, and timeouts.</p>
<div class="card-meta">
<span class="tag">fibers</span>
<span class="tag">scheduler</span>
</div>
</div>
<div class="card">
<h3><a href="error-handling.html">Error Handling</a></h3>
<p>Catch errors with fibers, validate input, and handle edge cases gracefully.</p>
<div class="card-meta">
<span class="tag">fibers</span>
</div>
</div>
</div>
<h2>How-To vs Tutorials</h2>
<p><strong>Tutorials</strong> are learning-oriented. They walk you through building complete applications step by step, introducing concepts gradually.</p>
<p><strong>How-To Guides</strong> are goal-oriented. They assume you know the basics and need to accomplish a specific task quickly. Each guide focuses on one topic with copy-paste examples.</p>
<h2>Quick Reference</h2>
<table>
<tr>
<th>Task</th>
<th>Guide</th>
<th>Key Functions</th>
</tr>
<tr>
<td>Fetch data from API</td>
<td><a href="http-requests.html">HTTP Requests</a></td>
<td><code>Http.get()</code>, <code>response.json</code></td>
</tr>
<tr>
<td>Parse JSON string</td>
<td><a href="json-parsing.html">JSON Parsing</a></td>
<td><code>Json.parse()</code></td>
</tr>
<tr>
<td>Validate email format</td>
<td><a href="regex-patterns.html">Regex Patterns</a></td>
<td><code>Regex.new().test()</code></td>
</tr>
<tr>
<td>Read file contents</td>
<td><a href="file-operations.html">File Operations</a></td>
<td><code>File.read()</code></td>
</tr>
<tr>
<td>Run tasks in parallel</td>
<td><a href="async-operations.html">Async Operations</a></td>
<td><code>Fiber.new { }</code></td>
</tr>
<tr>
<td>Handle runtime errors</td>
<td><a href="error-handling.html">Error Handling</a></td>
<td><code>fiber.try()</code></td>
</tr>
</table>
</article>
<footer class="page-footer">
<a href="../tutorials/cli-tool.html" class="prev">CLI Tool</a>
<a href="http-requests.html" class="next">HTTP Requests</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,371 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Working with JSON - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="index.html">How-To List</a></li>
<li><a href="http-requests.html">HTTP Requests</a></li>
<li><a href="json-parsing.html" class="active">JSON Parsing</a></li>
<li><a href="regex-patterns.html">Regex Patterns</a></li>
<li><a href="file-operations.html">File Operations</a></li>
<li><a href="async-operations.html">Async Operations</a></li>
<li><a href="error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">How-To Guides</a>
<span class="separator">/</span>
<span>JSON Parsing</span>
</nav>
<article>
<h1>Working with JSON</h1>
<h2>Parse JSON String</h2>
<pre><code>import "json" for Json
var jsonStr = '{"name": "Alice", "age": 30}'
var data = Json.parse(jsonStr)
System.print(data["name"]) // Alice
System.print(data["age"]) // 30</code></pre>
<h2>Parse JSON Array</h2>
<pre><code>import "json" for Json
var jsonStr = '[1, 2, 3, "four", true, null]'
var items = Json.parse(jsonStr)
for (item in items) {
System.print(item)
}</code></pre>
<h2>Access Nested Objects</h2>
<pre><code>import "json" for Json
var jsonStr = '{"user": {"name": "Bob", "address": {"city": "NYC"}}}'
var data = Json.parse(jsonStr)
System.print(data["user"]["name"]) // Bob
System.print(data["user"]["address"]["city"]) // NYC</code></pre>
<h2>Convert Wren Object to JSON</h2>
<pre><code>import "json" for Json
var data = {
"name": "Charlie",
"age": 25,
"active": true
}
var jsonStr = Json.stringify(data)
System.print(jsonStr) // {"name":"Charlie","age":25,"active":true}</code></pre>
<h2>Pretty Print JSON</h2>
<pre><code>import "json" for Json
var data = {
"users": [
{"name": "Alice", "age": 30},
{"name": "Bob", "age": 25}
]
}
var pretty = Json.stringify(data, 2)
System.print(pretty)</code></pre>
<p>Output:</p>
<pre><code>{
"users": [
{
"name": "Alice",
"age": 30
},
{
"name": "Bob",
"age": 25
}
]
}</code></pre>
<h2>Check if Key Exists</h2>
<pre><code>import "json" for Json
var data = Json.parse('{"name": "Alice"}')
if (data.containsKey("name")) {
System.print("Name: %(data["name"])")
}
if (!data.containsKey("age")) {
System.print("Age not specified")
}</code></pre>
<h2>Provide Default Values</h2>
<pre><code>import "json" for Json
var data = Json.parse('{"name": "Alice"}')
var name = data["name"]
var age = data.containsKey("age") ? data["age"] : 0
var city = data.containsKey("city") ? data["city"] : "Unknown"
System.print("%(name), %(age), %(city)")</code></pre>
<h2>Iterate Over Object Keys</h2>
<pre><code>import "json" for Json
var data = Json.parse('{"a": 1, "b": 2, "c": 3}')
for (key in data.keys) {
System.print("%(key): %(data[key])")
}</code></pre>
<h2>Iterate Over Array</h2>
<pre><code>import "json" for Json
var users = Json.parse('[{"name": "Alice"}, {"name": "Bob"}]')
for (i in 0...users.count) {
System.print("%(i + 1). %(users[i]["name"])")
}</code></pre>
<h2>Modify JSON Data</h2>
<pre><code>import "json" for Json
var data = Json.parse('{"name": "Alice", "age": 30}')
data["age"] = 31
data["email"] = "alice@example.com"
data.remove("name")
System.print(Json.stringify(data))</code></pre>
<h2>Parse JSON from File</h2>
<pre><code>import "json" for Json
import "io" for File
var content = File.read("config.json")
var config = Json.parse(content)
System.print(config["setting"])</code></pre>
<h2>Write JSON to File</h2>
<pre><code>import "json" for Json
import "io" for File
var data = {
"database": "myapp.db",
"port": 8080,
"debug": true
}
File.write("config.json", Json.stringify(data, 2))</code></pre>
<h2>Handle Parse Errors</h2>
<pre><code>import "json" for Json
var jsonStr = "invalid json {"
var fiber = Fiber.new { Json.parse(jsonStr) }
var result = fiber.try()
if (fiber.error) {
System.print("Parse error: %(fiber.error)")
} else {
System.print(result)
}</code></pre>
<h2>Work with Null Values</h2>
<pre><code>import "json" for Json
var data = Json.parse('{"name": "Alice", "address": null}')
if (data["address"] == null) {
System.print("No address provided")
}
var output = {"value": null}
System.print(Json.stringify(output)) // {"value":null}</code></pre>
<h2>Build JSON Array Dynamically</h2>
<pre><code>import "json" for Json
var users = []
users.add({"name": "Alice", "role": "admin"})
users.add({"name": "Bob", "role": "user"})
users.add({"name": "Charlie", "role": "user"})
System.print(Json.stringify(users, 2))</code></pre>
<h2>Filter JSON Array</h2>
<pre><code>import "json" for Json
var users = Json.parse('[
{"name": "Alice", "age": 30},
{"name": "Bob", "age": 17},
{"name": "Charlie", "age": 25}
]')
var adults = []
for (user in users) {
if (user["age"] >= 18) {
adults.add(user)
}
}
System.print("Adults: %(Json.stringify(adults))")</code></pre>
<h2>Transform JSON Data</h2>
<pre><code>import "json" for Json
var users = Json.parse('[
{"firstName": "Alice", "lastName": "Smith"},
{"firstName": "Bob", "lastName": "Jones"}
]')
var names = []
for (user in users) {
names.add("%(user["firstName"]) %(user["lastName"])")
}
System.print(names.join(", "))</code></pre>
<h2>Merge JSON Objects</h2>
<pre><code>import "json" for Json
var defaults = {"theme": "light", "language": "en", "timeout": 30}
var userPrefs = {"theme": "dark"}
var config = {}
for (key in defaults.keys) {
config[key] = defaults[key]
}
for (key in userPrefs.keys) {
config[key] = userPrefs[key]
}
System.print(Json.stringify(config, 2))</code></pre>
<div class="admonition tip">
<div class="admonition-title">See Also</div>
<p>For full API documentation, see the <a href="../api/json.html">JSON module reference</a>.</p>
</div>
</article>
<footer class="page-footer">
<a href="http-requests.html" class="prev">HTTP Requests</a>
<a href="regex-patterns.html" class="next">Regex Patterns</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,365 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Using Regular Expressions - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="index.html">How-To List</a></li>
<li><a href="http-requests.html">HTTP Requests</a></li>
<li><a href="json-parsing.html">JSON Parsing</a></li>
<li><a href="regex-patterns.html" class="active">Regex Patterns</a></li>
<li><a href="file-operations.html">File Operations</a></li>
<li><a href="async-operations.html">Async Operations</a></li>
<li><a href="error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">How-To Guides</a>
<span class="separator">/</span>
<span>Regex Patterns</span>
</nav>
<article>
<h1>Using Regular Expressions</h1>
<h2>Test if String Matches Pattern</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("^hello")
System.print(pattern.test("hello world")) // true
System.print(pattern.test("say hello")) // false</code></pre>
<h2>Find First Match</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("\\d+")
var match = pattern.match("Order 12345 shipped")
if (match) {
System.print(match.text) // 12345
System.print(match.start) // 6
System.print(match.end) // 11
}</code></pre>
<h2>Find All Matches</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("\\d+")
var matches = pattern.matchAll("Items: 10, 20, 30")
for (match in matches) {
System.print(match.text)
}
// 10
// 20
// 30</code></pre>
<h2>Capture Groups</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("(\\w+)@(\\w+\\.\\w+)")
var match = pattern.match("Contact: alice@example.com")
if (match) {
System.print(match.group(0)) // alice@example.com
System.print(match.group(1)) // alice
System.print(match.group(2)) // example.com
}</code></pre>
<h2>Replace Matches</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("\\bcat\\b")
var result = pattern.replace("The cat sat on the cat mat", "dog")
System.print(result) // The dog sat on the dog mat</code></pre>
<h2>Replace with Callback</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("\\d+")
var result = pattern.replace("a1b2c3", Fn.new { |match|
return "[%(match.text)]"
})
System.print(result) // a[1]b[2]c[3]</code></pre>
<h2>Split String</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("[,;\\s]+")
var parts = pattern.split("apple, banana; cherry date")
for (part in parts) {
System.print(part)
}
// apple
// banana
// cherry
// date</code></pre>
<h2>Case Insensitive Matching</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("hello", "i")
System.print(pattern.test("Hello World")) // true
System.print(pattern.test("HELLO")) // true</code></pre>
<h2>Multiline Matching</h2>
<pre><code>import "regex" for Regex
var text = "Line 1\nLine 2\nLine 3"
var pattern = Regex.new("^Line", "m")
var matches = pattern.matchAll(text)
System.print(matches.count) // 3</code></pre>
<h2>Common Patterns</h2>
<h3>Validate Email</h3>
<pre><code>import "regex" for Regex
var emailPattern = Regex.new("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$")
System.print(emailPattern.test("user@example.com")) // true
System.print(emailPattern.test("invalid-email")) // false</code></pre>
<h3>Validate URL</h3>
<pre><code>import "regex" for Regex
var urlPattern = Regex.new("^https?://[a-zA-Z0-9.-]+(/.*)?$")
System.print(urlPattern.test("https://example.com")) // true
System.print(urlPattern.test("http://example.com/path")) // true
System.print(urlPattern.test("ftp://invalid")) // false</code></pre>
<h3>Validate Phone Number</h3>
<pre><code>import "regex" for Regex
var phonePattern = Regex.new("^\\+?\\d{1,3}[-.\\s]?\\(?\\d{3}\\)?[-.\\s]?\\d{3}[-.\\s]?\\d{4}$")
System.print(phonePattern.test("+1-555-123-4567")) // true
System.print(phonePattern.test("(555) 123-4567")) // true</code></pre>
<h3>Extract Numbers</h3>
<pre><code>import "regex" for Regex
var numberPattern = Regex.new("-?\\d+\\.?\\d*")
var text = "Temperature: -5.5 to 32.0 degrees"
var matches = numberPattern.matchAll(text)
for (match in matches) {
System.print(match.text)
}
// -5.5
// 32.0</code></pre>
<h3>Extract Hashtags</h3>
<pre><code>import "regex" for Regex
var hashtagPattern = Regex.new("#\\w+")
var text = "Check out #wren and #programming!"
var matches = hashtagPattern.matchAll(text)
for (match in matches) {
System.print(match.text)
}
// #wren
// #programming</code></pre>
<h3>Remove HTML Tags</h3>
<pre><code>import "regex" for Regex
var tagPattern = Regex.new("<[^>]+>")
var html = "<p>Hello <b>World</b>!</p>"
var text = tagPattern.replace(html, "")
System.print(text) // Hello World!</code></pre>
<h3>Validate Password Strength</h3>
<pre><code>import "regex" for Regex
var hasUpper = Regex.new("[A-Z]")
var hasLower = Regex.new("[a-z]")
var hasDigit = Regex.new("\\d")
var hasSpecial = Regex.new("[!@#$%^&*]")
var minLength = 8
var validatePassword = Fn.new { |password|
if (password.count < minLength) return false
if (!hasUpper.test(password)) return false
if (!hasLower.test(password)) return false
if (!hasDigit.test(password)) return false
if (!hasSpecial.test(password)) return false
return true
}
System.print(validatePassword.call("Weak")) // false
System.print(validatePassword.call("Strong@Pass1")) // true</code></pre>
<h3>Parse Log Lines</h3>
<pre><code>import "regex" for Regex
var logPattern = Regex.new("\\[(\\d{4}-\\d{2}-\\d{2})\\]\\s+(\\w+):\\s+(.+)")
var line = "[2024-01-15] ERROR: Connection failed"
var match = logPattern.match(line)
if (match) {
System.print("Date: %(match.group(1))") // 2024-01-15
System.print("Level: %(match.group(2))") // ERROR
System.print("Message: %(match.group(3))") // Connection failed
}</code></pre>
<h3>Validate IP Address</h3>
<pre><code>import "regex" for Regex
var ipPattern = Regex.new("^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$")
System.print(ipPattern.test("192.168.1.1")) // true
System.print(ipPattern.test("256.1.1.1")) // false
System.print(ipPattern.test("10.0.0.255")) // true</code></pre>
<h2>Pattern Syntax Quick Reference</h2>
<table>
<tr><th>Pattern</th><th>Description</th></tr>
<tr><td><code>.</code></td><td>Any character except newline</td></tr>
<tr><td><code>\\d</code></td><td>Digit (0-9)</td></tr>
<tr><td><code>\\w</code></td><td>Word character (a-z, A-Z, 0-9, _)</td></tr>
<tr><td><code>\\s</code></td><td>Whitespace</td></tr>
<tr><td><code>^</code></td><td>Start of string/line</td></tr>
<tr><td><code>$</code></td><td>End of string/line</td></tr>
<tr><td><code>*</code></td><td>Zero or more</td></tr>
<tr><td><code>+</code></td><td>One or more</td></tr>
<tr><td><code>?</code></td><td>Zero or one</td></tr>
<tr><td><code>{n,m}</code></td><td>Between n and m times</td></tr>
<tr><td><code>[abc]</code></td><td>Character class</td></tr>
<tr><td><code>[^abc]</code></td><td>Negated character class</td></tr>
<tr><td><code>(group)</code></td><td>Capture group</td></tr>
<tr><td><code>a|b</code></td><td>Alternation (a or b)</td></tr>
<tr><td><code>\\b</code></td><td>Word boundary</td></tr>
</table>
<div class="admonition tip">
<div class="admonition-title">See Also</div>
<p>For full API documentation, see the <a href="../api/regex.html">Regex module reference</a>.</p>
</div>
</article>
<footer class="page-footer">
<a href="json-parsing.html" class="prev">JSON Parsing</a>
<a href="file-operations.html" class="next">File Operations</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,224 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wren-CLI Manual</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="getting-started/index.html">Overview</a></li>
<li><a href="getting-started/installation.html">Installation</a></li>
<li><a href="getting-started/first-script.html">First Script</a></li>
<li><a href="getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="language/index.html">Syntax Overview</a></li>
<li><a href="language/classes.html">Classes</a></li>
<li><a href="language/methods.html">Methods</a></li>
<li><a href="language/control-flow.html">Control Flow</a></li>
<li><a href="language/fibers.html">Fibers</a></li>
<li><a href="language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="api/index.html">Overview</a></li>
<li><a href="api/string.html">String</a></li>
<li><a href="api/number.html">Num</a></li>
<li><a href="api/argparse.html">argparse</a></li>
<li><a href="api/base64.html">base64</a></li>
<li><a href="api/crypto.html">crypto</a></li>
<li><a href="api/dataset.html">dataset</a></li>
<li><a href="api/datetime.html">datetime</a></li>
<li><a href="api/dns.html">dns</a></li>
<li><a href="api/env.html">env</a></li>
<li><a href="api/fswatch.html">fswatch</a></li>
<li><a href="api/html.html">html</a></li>
<li><a href="api/http.html">http</a></li>
<li><a href="api/io.html">io</a></li>
<li><a href="api/jinja.html">jinja</a></li>
<li><a href="api/json.html">json</a></li>
<li><a href="api/markdown.html">markdown</a></li>
<li><a href="api/math.html">math</a></li>
<li><a href="api/net.html">net</a></li>
<li><a href="api/os.html">os</a></li>
<li><a href="api/pathlib.html">pathlib</a></li>
<li><a href="api/regex.html">regex</a></li>
<li><a href="api/scheduler.html">scheduler</a></li>
<li><a href="api/signal.html">signal</a></li>
<li><a href="api/sqlite.html">sqlite</a></li>
<li><a href="api/subprocess.html">subprocess</a></li>
<li><a href="api/sysinfo.html">sysinfo</a></li>
<li><a href="api/tempfile.html">tempfile</a></li>
<li><a href="api/timer.html">timer</a></li>
<li><a href="api/tls.html">tls</a></li>
<li><a href="api/udp.html">udp</a></li>
<li><a href="api/uuid.html">uuid</a></li>
<li><a href="api/wdantic.html">wdantic</a></li>
<li><a href="api/web.html">web</a></li>
<li><a href="api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="tutorials/index.html">Tutorial List</a></li>
<li><a href="tutorials/http-client.html">HTTP Client</a></li>
<li><a href="tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="tutorials/database-app.html">Database App</a></li>
<li><a href="tutorials/template-rendering.html">Templates</a></li>
<li><a href="tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="howto/index.html">How-To List</a></li>
<li><a href="howto/http-requests.html">HTTP Requests</a></li>
<li><a href="howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="howto/file-operations.html">File Operations</a></li>
<li><a href="howto/async-operations.html">Async Operations</a></li>
<li><a href="howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="contributing/index.html">Overview</a></li>
<li><a href="contributing/module-overview.html">Module Architecture</a></li>
<li><a href="contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="contributing/testing.html">Writing Tests</a></li>
<li><a href="contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<div class="hero">
<h1>Wren-CLI Manual</h1>
<p>A complete reference for the Wren scripting language command-line interface with networking, async I/O, and extended module support.</p>
<div class="hero-buttons">
<a href="getting-started/index.html" class="primary-btn">Get Started</a>
<a href="api/index.html" class="secondary-btn">API Reference</a>
</div>
</div>
<article>
<h2>What is Wren-CLI?</h2>
<p>Wren-CLI is a command-line interface for the <a href="https://wren.io">Wren programming language</a>, extended with powerful modules for networking, file I/O, databases, and more. It provides an async event loop powered by libuv, making it suitable for building servers, automation scripts, and command-line tools.</p>
<div class="card-grid">
<div class="card">
<h3><a href="getting-started/index.html">Getting Started</a></h3>
<p>Install Wren-CLI, write your first script, and learn the basics of the language.</p>
</div>
<div class="card">
<h3><a href="language/index.html">Language Reference</a></h3>
<p>Learn about classes, methods, control flow, fibers, and the module system.</p>
</div>
<div class="card">
<h3><a href="api/index.html">API Reference</a></h3>
<p>Complete documentation for all 32 built-in modules including HTTP, WebSocket, and SQLite.</p>
</div>
<div class="card">
<h3><a href="tutorials/index.html">Tutorials</a></h3>
<p>Step-by-step guides for building real applications with Wren-CLI.</p>
</div>
</div>
<h2>Available Modules</h2>
<p>Wren-CLI provides a rich set of modules for common programming tasks:</p>
<h3>Networking</h3>
<div class="module-grid">
<a href="api/http.html" class="module-card">http</a>
<a href="api/websocket.html" class="module-card">websocket</a>
<a href="api/tls.html" class="module-card">tls</a>
<a href="api/net.html" class="module-card">net</a>
<a href="api/udp.html" class="module-card">udp</a>
<a href="api/dns.html" class="module-card">dns</a>
</div>
<h3>Data Processing</h3>
<div class="module-grid">
<a href="api/json.html" class="module-card">json</a>
<a href="api/base64.html" class="module-card">base64</a>
<a href="api/regex.html" class="module-card">regex</a>
<a href="api/jinja.html" class="module-card">jinja</a>
<a href="api/crypto.html" class="module-card">crypto</a>
</div>
<h3>System</h3>
<div class="module-grid">
<a href="api/os.html" class="module-card">os</a>
<a href="api/env.html" class="module-card">env</a>
<a href="api/signal.html" class="module-card">signal</a>
<a href="api/subprocess.html" class="module-card">subprocess</a>
<a href="api/io.html" class="module-card">io</a>
<a href="api/pathlib.html" class="module-card">pathlib</a>
<a href="api/sysinfo.html" class="module-card">sysinfo</a>
<a href="api/fswatch.html" class="module-card">fswatch</a>
</div>
<h3>Data & Time</h3>
<div class="module-grid">
<a href="api/sqlite.html" class="module-card">sqlite</a>
<a href="api/datetime.html" class="module-card">datetime</a>
<a href="api/timer.html" class="module-card">timer</a>
<a href="api/math.html" class="module-card">math</a>
<a href="api/scheduler.html" class="module-card">scheduler</a>
</div>
<h2>Quick Example</h2>
<pre><code>import "http" for Http
import "json" for Json
var response = Http.get("https://api.github.com/users/wren-lang")
var data = Json.parse(response.body)
System.print("User: %(data["login"])")
System.print("Repos: %(data["public_repos"])")</code></pre>
<h2>Features</h2>
<ul>
<li><strong>Async I/O</strong> - Non-blocking operations powered by libuv</li>
<li><strong>HTTP/HTTPS</strong> - Full HTTP client with TLS support</li>
<li><strong>WebSocket</strong> - Client and server WebSocket support</li>
<li><strong>SQLite</strong> - Embedded database for persistent storage</li>
<li><strong>Templates</strong> - Jinja2-compatible template engine</li>
<li><strong>Regex</strong> - Full regular expression support</li>
<li><strong>Cross-platform</strong> - Runs on Linux, macOS, and FreeBSD</li>
</ul>
</article>
<footer class="page-footer">
<span></span>
<a href="getting-started/index.html" class="next">Getting Started</a>
</footer>
</main>
</div>
<script src="js/main.js"></script>
</body>
</html>

View File

@ -1,112 +0,0 @@
// retoor <retoor@molodetz.nl>
(function() {
'use strict';
function initSidebar() {
var toggle = document.querySelector('.mobile-menu-toggle');
var sidebar = document.querySelector('.sidebar');
var overlay = document.createElement('div');
overlay.className = 'sidebar-overlay';
document.body.appendChild(overlay);
if (toggle) {
toggle.addEventListener('click', function() {
sidebar.classList.toggle('open');
overlay.classList.toggle('visible');
});
}
overlay.addEventListener('click', function() {
sidebar.classList.remove('open');
overlay.classList.remove('visible');
});
var currentPath = window.location.pathname;
var links = document.querySelectorAll('.sidebar-nav a');
links.forEach(function(link) {
var href = link.getAttribute('href');
if (href && currentPath.endsWith(href.replace(/^\.\.\//, '').replace(/^\.\//, ''))) {
link.classList.add('active');
}
});
}
function initCopyButtons() {
var codeBlocks = document.querySelectorAll('pre');
codeBlocks.forEach(function(pre) {
var wrapper = document.createElement('div');
wrapper.className = 'code-block';
pre.parentNode.insertBefore(wrapper, pre);
wrapper.appendChild(pre);
var btn = document.createElement('button');
btn.className = 'copy-btn';
btn.textContent = 'Copy';
wrapper.appendChild(btn);
btn.addEventListener('click', function() {
var code = pre.querySelector('code');
var text = code ? code.textContent : pre.textContent;
navigator.clipboard.writeText(text).then(function() {
btn.textContent = 'Copied!';
btn.classList.add('copied');
setTimeout(function() {
btn.textContent = 'Copy';
btn.classList.remove('copied');
}, 2000);
}).catch(function() {
btn.textContent = 'Failed';
setTimeout(function() {
btn.textContent = 'Copy';
}, 2000);
});
});
});
}
function initSmoothScroll() {
document.querySelectorAll('a[href^="#"]').forEach(function(anchor) {
anchor.addEventListener('click', function(e) {
var targetId = this.getAttribute('href').slice(1);
var target = document.getElementById(targetId);
if (target) {
e.preventDefault();
target.scrollIntoView({ behavior: 'smooth' });
history.pushState(null, null, '#' + targetId);
}
});
});
}
function highlightCode() {
var keywords = ['import', 'for', 'class', 'static', 'var', 'if', 'else', 'while',
'return', 'true', 'false', 'null', 'this', 'super', 'is', 'new',
'foreign', 'construct', 'break', 'continue', 'in'];
document.querySelectorAll('pre code').forEach(function(block) {
if (block.classList.contains('highlighted')) return;
block.classList.add('highlighted');
var html = block.innerHTML;
html = html.replace(/(\/\/[^\n]*)/g, '<span style="color:#6a9955">$1</span>');
html = html.replace(/("(?:[^"\\]|\\.)*")/g, '<span style="color:#ce9178">$1</span>');
keywords.forEach(function(kw) {
var regex = new RegExp('\\b(' + kw + ')\\b', 'g');
html = html.replace(regex, '<span style="color:#569cd6">$1</span>');
});
block.innerHTML = html;
});
}
document.addEventListener('DOMContentLoaded', function() {
initSidebar();
initCopyButtons();
initSmoothScroll();
highlightCode();
});
})();

View File

@ -1,450 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Classes - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="index.html">Syntax Overview</a></li>
<li><a href="classes.html" class="active">Classes</a></li>
<li><a href="methods.html">Methods</a></li>
<li><a href="control-flow.html">Control Flow</a></li>
<li><a href="fibers.html">Fibers</a></li>
<li><a href="modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Language</a>
<span class="separator">/</span>
<span>Classes</span>
</nav>
<article>
<h1>Classes</h1>
<p>Wren is a class-based object-oriented language. Everything in Wren is an object, and every object is an instance of a class.</p>
<h2>Defining Classes</h2>
<p>Define a class with the <code>class</code> keyword:</p>
<pre><code>class Animal {
}</code></pre>
<p>This creates a class named <code>Animal</code> with no methods or fields.</p>
<h2>Constructors</h2>
<p>Constructors create new instances. Define them with <code>construct</code>:</p>
<pre><code>class Person {
construct new(name, age) {
_name = name
_age = age
}
}
var alice = Person.new("Alice", 30)</code></pre>
<p>A class can have multiple named constructors:</p>
<pre><code>class Point {
construct new(x, y) {
_x = x
_y = y
}
construct origin() {
_x = 0
_y = 0
}
construct fromList(list) {
_x = list[0]
_y = list[1]
}
}
var p1 = Point.new(3, 4)
var p2 = Point.origin()
var p3 = Point.fromList([5, 6])</code></pre>
<h2>Fields</h2>
<p>Instance fields are prefixed with <code>_</code>. They are private to the class:</p>
<pre><code>class Counter {
construct new() {
_count = 0
}
increment() {
_count = _count + 1
}
count { _count }
}</code></pre>
<p>Fields are not declared; they are created when first assigned.</p>
<h2>Getters and Setters</h2>
<p>Getters are methods without parentheses:</p>
<pre><code>class Circle {
construct new(radius) {
_radius = radius
}
radius { _radius }
area { 3.14159 * _radius * _radius }
}
var c = Circle.new(5)
System.print(c.radius) // 5
System.print(c.area) // 78.53975</code></pre>
<p>Setters use <code>=</code> suffix:</p>
<pre><code>class Circle {
construct new(radius) {
_radius = radius
}
radius { _radius }
radius=(value) { _radius = value }
}
var c = Circle.new(5)
c.radius = 10
System.print(c.radius) // 10</code></pre>
<h2>Methods</h2>
<p>Methods are defined inside the class body:</p>
<pre><code>class Rectangle {
construct new(width, height) {
_width = width
_height = height
}
area() {
return _width * _height
}
perimeter() {
return 2 * (_width + _height)
}
}
var rect = Rectangle.new(4, 5)
System.print(rect.area()) // 20
System.print(rect.perimeter()) // 18</code></pre>
<h2>Static Members</h2>
<p>Static methods and fields belong to the class, not instances:</p>
<pre><code>class Math {
static pi { 3.14159 }
static square(x) {
return x * x
}
static cube(x) {
return x * x * x
}
}
System.print(Math.pi) // 3.14159
System.print(Math.square(4)) // 16
System.print(Math.cube(3)) // 27</code></pre>
<p>Static fields use double underscore:</p>
<pre><code>class Counter {
static count { __count }
static increment() {
if (__count == null) __count = 0
__count = __count + 1
}
}
Counter.increment()
Counter.increment()
System.print(Counter.count) // 2</code></pre>
<h2>Inheritance</h2>
<p>Classes can inherit from a single superclass using <code>is</code>:</p>
<pre><code>class Animal {
construct new(name) {
_name = name
}
name { _name }
speak() {
System.print("...")
}
}
class Dog is Animal {
construct new(name, breed) {
super(name)
_breed = breed
}
breed { _breed }
speak() {
System.print("Woof!")
}
}
var dog = Dog.new("Rex", "German Shepherd")
System.print(dog.name) // Rex
System.print(dog.breed) // German Shepherd
dog.speak() // Woof!</code></pre>
<h3>Calling Super</h3>
<p>Use <code>super</code> to call the superclass constructor or methods:</p>
<pre><code>class Parent {
construct new() {
_value = 10
}
value { _value }
describe() {
System.print("Parent value: %(_value)")
}
}
class Child is Parent {
construct new() {
super()
_extra = 20
}
describe() {
super.describe()
System.print("Child extra: %(_extra)")
}
}
var child = Child.new()
child.describe()
// Output:
// Parent value: 10
// Child extra: 20</code></pre>
<h2>This</h2>
<p>Use <code>this</code> to refer to the current instance:</p>
<pre><code>class Node {
construct new(value) {
_value = value
_next = null
}
value { _value }
next { _next }
append(value) {
_next = Node.new(value)
return this
}
}
var n = Node.new(1).append(2).append(3)</code></pre>
<h2>Object Class</h2>
<p>All classes implicitly inherit from <code>Object</code>:</p>
<pre><code>class Foo {}
System.print(Foo is Class) // true
System.print(Foo.supertype) // Object</code></pre>
<h2>Type Checking</h2>
<p>Use <code>is</code> to check if an object is an instance of a class:</p>
<pre><code>var dog = Dog.new("Rex", "Shepherd")
System.print(dog is Dog) // true
System.print(dog is Animal) // true
System.print(dog is Object) // true
System.print(dog is String) // false</code></pre>
<p>Get the class of an object with <code>type</code>:</p>
<pre><code>System.print(dog.type) // Dog
System.print(dog.type.name) // Dog
System.print(dog.type.supertype) // Animal</code></pre>
<h2>Foreign Classes</h2>
<p>Foreign classes are implemented in C. They can hold native data:</p>
<pre><code>foreign class Socket {
construct new() {}
foreign connect(host, port)
foreign send(data)
foreign receive()
foreign close()
}</code></pre>
<p>Foreign classes are used by built-in modules to provide native functionality.</p>
<h2>Complete Example</h2>
<pre><code>class Shape {
construct new() {}
area { 0 }
perimeter { 0 }
describe() {
System.print("Area: %(area)")
System.print("Perimeter: %(perimeter)")
}
}
class Rectangle is Shape {
construct new(width, height) {
_width = width
_height = height
}
width { _width }
height { _height }
area { _width * _height }
perimeter { 2 * (_width + _height) }
}
class Square is Rectangle {
construct new(side) {
super(side, side)
}
}
class Circle is Shape {
construct new(radius) {
_radius = radius
}
static pi { 3.14159 }
radius { _radius }
area { Circle.pi * _radius * _radius }
perimeter { 2 * Circle.pi * _radius }
}
var shapes = [
Rectangle.new(4, 5),
Square.new(3),
Circle.new(2)
]
for (shape in shapes) {
System.print("%(shape.type.name):")
shape.describe()
System.print("")
}</code></pre>
</article>
<footer class="page-footer">
<a href="index.html" class="prev">Syntax Overview</a>
<a href="methods.html" class="next">Methods</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,360 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Control Flow - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="index.html">Syntax Overview</a></li>
<li><a href="classes.html">Classes</a></li>
<li><a href="methods.html">Methods</a></li>
<li><a href="control-flow.html" class="active">Control Flow</a></li>
<li><a href="fibers.html">Fibers</a></li>
<li><a href="modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Language</a>
<span class="separator">/</span>
<span>Control Flow</span>
</nav>
<article>
<h1>Control Flow</h1>
<p>Wren provides standard control flow constructs for conditionals, loops, and early exit.</p>
<h2>Truthiness</h2>
<p>Before covering control flow, understand how Wren evaluates truthiness:</p>
<ul>
<li><code>false</code> is falsy</li>
<li><code>null</code> is falsy</li>
<li>Everything else is truthy (including <code>0</code>, <code>""</code>, <code>[]</code>)</li>
</ul>
<pre><code>if (0) System.print("0 is truthy")
if ("") System.print("empty string is truthy")
if ([]) System.print("empty list is truthy")
if (false) System.print("false is falsy") // Not printed
if (null) System.print("null is falsy") // Not printed</code></pre>
<h2>If Statements</h2>
<p>Basic conditional execution:</p>
<pre><code>if (condition) {
System.print("condition is true")
}</code></pre>
<h3>If-Else</h3>
<pre><code>if (score >= 90) {
System.print("A")
} else {
System.print("Not A")
}</code></pre>
<h3>If-Else If-Else</h3>
<pre><code>if (score >= 90) {
System.print("A")
} else if (score >= 80) {
System.print("B")
} else if (score >= 70) {
System.print("C")
} else {
System.print("F")
}</code></pre>
<h3>Single Expression</h3>
<p>For single expressions, braces are optional:</p>
<pre><code>if (x > 0) System.print("positive")</code></pre>
<h2>Ternary Operator</h2>
<p>For inline conditionals:</p>
<pre><code>var status = age >= 18 ? "adult" : "minor"
var max = a > b ? a : b</code></pre>
<h2>Logical Operators</h2>
<h3>And (&&)</h3>
<p>Returns the first falsy value or the last value:</p>
<pre><code>System.print(true && false) // false
System.print(true && true) // true
System.print(1 && 2) // 2
System.print(null && 1) // null</code></pre>
<h3>Or (||)</h3>
<p>Returns the first truthy value or the last value:</p>
<pre><code>System.print(false || true) // true
System.print(false || false) // false
System.print(null || "default") // default
System.print(1 || 2) // 1</code></pre>
<p>Use <code>||</code> for default values:</p>
<pre><code>var name = providedName || "Anonymous"</code></pre>
<h2>While Loops</h2>
<p>Repeat while a condition is true:</p>
<pre><code>var i = 0
while (i &lt; 5) {
System.print(i)
i = i + 1
}</code></pre>
<div class="example-output">0
1
2
3
4</div>
<h2>For Loops</h2>
<p>Iterate over any sequence:</p>
<pre><code>for (item in [1, 2, 3]) {
System.print(item)
}</code></pre>
<h3>Range Iteration</h3>
<pre><code>for (i in 1..5) {
System.print(i)
}
// Prints: 1 2 3 4 5
for (i in 1...5) {
System.print(i)
}
// Prints: 1 2 3 4 (exclusive)</code></pre>
<h3>String Iteration</h3>
<pre><code>for (char in "hello") {
System.print(char)
}
// Prints each character</code></pre>
<h3>Map Iteration</h3>
<pre><code>var person = {"name": "Alice", "age": 30}
for (key in person.keys) {
System.print("%(key): %(person[key])")
}</code></pre>
<h2>Break</h2>
<p>Exit a loop early:</p>
<pre><code>for (i in 1..100) {
if (i > 5) break
System.print(i)
}
// Prints: 1 2 3 4 5</code></pre>
<h2>Continue</h2>
<p>Skip to the next iteration:</p>
<pre><code>for (i in 1..10) {
if (i % 2 == 0) continue
System.print(i)
}
// Prints: 1 3 5 7 9 (odd numbers only)</code></pre>
<h2>Block Scoping</h2>
<p>Blocks create new scopes:</p>
<pre><code>var x = "outer"
{
var x = "inner"
System.print(x) // inner
}
System.print(x) // outer</code></pre>
<p>Variables declared in a block are not visible outside:</p>
<pre><code>if (true) {
var temp = "temporary"
}
// temp is not accessible here</code></pre>
<h2>Iterating with Index</h2>
<p>Use range to get indices:</p>
<pre><code>var list = ["a", "b", "c"]
for (i in 0...list.count) {
System.print("%(i): %(list[i])")
}</code></pre>
<div class="example-output">0: a
1: b
2: c</div>
<h2>Infinite Loops</h2>
<p>Create with <code>while (true)</code>:</p>
<pre><code>var count = 0
while (true) {
count = count + 1
if (count >= 5) break
System.print(count)
}</code></pre>
<h2>Nested Loops</h2>
<pre><code>for (i in 1..3) {
for (j in 1..3) {
System.print("%(i), %(j)")
}
}</code></pre>
<p>Break only exits the innermost loop:</p>
<pre><code>for (i in 1..3) {
for (j in 1..10) {
if (j > 2) break // Only breaks inner loop
System.print("%(i), %(j)")
}
}</code></pre>
<h2>Iteration Patterns</h2>
<h3>Filtering</h3>
<pre><code>var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
var evens = []
for (n in numbers) {
if (n % 2 == 0) evens.add(n)
}
System.print(evens) // [2, 4, 6, 8, 10]</code></pre>
<h3>Mapping</h3>
<pre><code>var numbers = [1, 2, 3, 4, 5]
var squared = []
for (n in numbers) {
squared.add(n * n)
}
System.print(squared) // [1, 4, 9, 16, 25]</code></pre>
<h3>Finding</h3>
<pre><code>var numbers = [1, 3, 5, 8, 9, 11]
var firstEven = null
for (n in numbers) {
if (n % 2 == 0) {
firstEven = n
break
}
}
System.print(firstEven) // 8</code></pre>
<h3>Reducing</h3>
<pre><code>var numbers = [1, 2, 3, 4, 5]
var sum = 0
for (n in numbers) {
sum = sum + n
}
System.print(sum) // 15</code></pre>
<h2>Functional Alternatives</h2>
<p>Lists provide functional methods that are often cleaner:</p>
<pre><code>var numbers = [1, 2, 3, 4, 5]
var evens = numbers.where { |n| n % 2 == 0 }.toList
var squared = numbers.map { |n| n * n }.toList
var sum = numbers.reduce(0) { |acc, n| acc + n }</code></pre>
</article>
<footer class="page-footer">
<a href="methods.html" class="prev">Methods</a>
<a href="fibers.html" class="next">Fibers</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,330 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Syntax Overview - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="index.html" class="active">Syntax Overview</a></li>
<li><a href="classes.html">Classes</a></li>
<li><a href="methods.html">Methods</a></li>
<li><a href="control-flow.html">Control Flow</a></li>
<li><a href="fibers.html">Fibers</a></li>
<li><a href="modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<span>Language Reference</span>
</nav>
<article>
<h1>Syntax Overview</h1>
<p>Wren is a small, fast, class-based scripting language with a clean syntax inspired by languages like Dart, Lua, and Smalltalk. This section covers the core language features.</p>
<div class="toc">
<h4>Language Topics</h4>
<ul>
<li><a href="classes.html">Classes</a> - Object-oriented programming</li>
<li><a href="methods.html">Methods</a> - Method definition and operators</li>
<li><a href="control-flow.html">Control Flow</a> - Conditionals and loops</li>
<li><a href="fibers.html">Fibers</a> - Cooperative concurrency</li>
<li><a href="modules.html">Modules</a> - Import system</li>
</ul>
</div>
<h2>Comments</h2>
<p>Single-line comments start with <code>//</code>:</p>
<pre><code>// This is a comment
var x = 42 // Inline comment</code></pre>
<p>Block comments use <code>/* */</code> and can nest:</p>
<pre><code>/* This is a
multi-line comment */
/* Outer /* nested */ comment */</code></pre>
<h2>Variables</h2>
<p>Declare variables with <code>var</code>:</p>
<pre><code>var name = "Wren"
var count = 42
var active = true
var nothing = null</code></pre>
<p>Variables must be initialized when declared. They are lexically scoped:</p>
<pre><code>var outer = "outside"
{
var inner = "inside"
System.print(outer) // Works
}
// inner is not accessible here</code></pre>
<h2>Data Types</h2>
<h3>Numbers</h3>
<p>All numbers are 64-bit floating point:</p>
<pre><code>var integer = 42
var decimal = 3.14159
var negative = -100
var scientific = 1.5e10
var hex = 0xFF
var binary = 0b1010</code></pre>
<h3>Strings</h3>
<p>Strings are immutable sequences of bytes:</p>
<pre><code>var single = "Hello"
var escape = "Line 1\nLine 2"
var interpolation = "Value: %(1 + 2)"</code></pre>
<p>Raw strings avoid escape processing:</p>
<pre><code>var raw = """
This is a raw string.
Backslashes \ are literal.
"""</code></pre>
<h3>Booleans</h3>
<pre><code>var yes = true
var no = false</code></pre>
<p>Only <code>false</code> and <code>null</code> are falsy. All other values, including <code>0</code> and empty strings, are truthy.</p>
<h3>Null</h3>
<pre><code>var nothing = null</code></pre>
<h3>Ranges</h3>
<p>Ranges represent sequences of numbers:</p>
<pre><code>var inclusive = 1..5 // 1, 2, 3, 4, 5
var exclusive = 1...5 // 1, 2, 3, 4</code></pre>
<h3>Lists</h3>
<p>Ordered, indexable collections:</p>
<pre><code>var empty = []
var numbers = [1, 2, 3, 4, 5]
var mixed = [1, "two", true, null]
System.print(numbers[0]) // 1
System.print(numbers[-1]) // 5 (last element)
numbers[0] = 10
numbers.add(6)</code></pre>
<h3>Maps</h3>
<p>Key-value collections:</p>
<pre><code>var empty = {}
var person = {
"name": "Alice",
"age": 30
}
System.print(person["name"]) // Alice
person["city"] = "Amsterdam"</code></pre>
<h2>Operators</h2>
<h3>Arithmetic</h3>
<pre><code>1 + 2 // 3
5 - 3 // 2
4 * 3 // 12
10 / 4 // 2.5
10 % 3 // 1 (modulo)</code></pre>
<h3>Comparison</h3>
<pre><code>1 == 1 // true
1 != 2 // true
1 &lt; 2 // true
1 &lt;= 1 // true
2 > 1 // true
2 >= 2 // true</code></pre>
<h3>Logical</h3>
<pre><code>true && false // false
true || false // true
!true // false</code></pre>
<p>Logical operators short-circuit:</p>
<pre><code>false && expensive() // expensive() not called
true || expensive() // expensive() not called</code></pre>
<h3>Bitwise</h3>
<pre><code>5 & 3 // 1 (AND)
5 | 3 // 7 (OR)
5 ^ 3 // 6 (XOR)
~5 // -6 (NOT)
8 &lt;&lt; 2 // 32 (left shift)
8 >> 2 // 2 (right shift)</code></pre>
<h3>Ternary</h3>
<pre><code>var result = condition ? valueIfTrue : valueIfFalse</code></pre>
<h2>String Interpolation</h2>
<p>Embed expressions in strings with <code>%()</code>:</p>
<pre><code>var name = "World"
System.print("Hello, %(name)!")
var a = 3
var b = 4
System.print("%(a) + %(b) = %(a + b)")</code></pre>
<p>Any expression can be interpolated:</p>
<pre><code>System.print("Random: %(Random.new().float())")
System.print("List: %([1, 2, 3].map { |x| x * 2 })")</code></pre>
<h2>Blocks</h2>
<p>Blocks are anonymous functions. They use curly braces:</p>
<pre><code>var block = { System.print("Hello") }
block.call()
var add = { |a, b| a + b }
System.print(add.call(1, 2)) // 3</code></pre>
<p>Blocks with a single expression return that value:</p>
<pre><code>var square = { |x| x * x }
System.print(square.call(5)) // 25</code></pre>
<h2>Functions</h2>
<p>Use <code>Fn.new</code> for functions stored in variables:</p>
<pre><code>var greet = Fn.new { |name|
return "Hello, %(name)!"
}
System.print(greet.call("World"))</code></pre>
<p>Functions can have multiple statements:</p>
<pre><code>var factorial = Fn.new { |n|
if (n &lt;= 1) return 1
return n * factorial.call(n - 1)
}</code></pre>
<h2>Is Operator</h2>
<p>Check if an object is an instance of a class:</p>
<pre><code>"hello" is String // true
42 is Num // true
[1, 2] is List // true</code></pre>
<h2>Reserved Words</h2>
<p>The following are reserved and cannot be used as identifiers:</p>
<pre><code>break class construct else false for foreign if import
in is null return static super this true var while</code></pre>
<h2>Identifiers</h2>
<p>Identifiers follow these conventions:</p>
<ul>
<li><code>camelCase</code> for variables and methods</li>
<li><code>PascalCase</code> for class names</li>
<li><code>_underscore</code> prefix for private fields</li>
<li><code>UPPER_CASE</code> for constants (by convention)</li>
</ul>
</article>
<footer class="page-footer">
<a href="../getting-started/repl.html" class="prev">Using the REPL</a>
<a href="classes.html" class="next">Classes</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -1,218 +0,0 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tutorials - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="index.html" class="active">Tutorial List</a></li>
<li><a href="http-client.html">HTTP Client</a></li>
<li><a href="websocket-chat.html">WebSocket Chat</a></li>
<li><a href="database-app.html">Database App</a></li>
<li><a href="template-rendering.html">Templates</a></li>
<li><a href="cli-tool.html">CLI Tool</a></li>
<li><a href="web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<span>Tutorials</span>
</nav>
<article>
<h1>Tutorials</h1>
<p>Step-by-step tutorials that guide you through building complete applications with Wren-CLI. Each tutorial introduces new concepts and builds upon previous knowledge.</p>
<div class="card-grid">
<div class="card">
<h3><a href="http-client.html">Building an HTTP Client</a></h3>
<p>Learn to make HTTP requests, parse JSON responses, and handle errors while building a REST API client.</p>
<div class="card-meta">
<span class="tag">http</span>
<span class="tag">json</span>
</div>
</div>
<div class="card">
<h3><a href="websocket-chat.html">WebSocket Chat Application</a></h3>
<p>Build a real-time chat application using WebSockets with both client and server components.</p>
<div class="card-meta">
<span class="tag">websocket</span>
<span class="tag">fibers</span>
</div>
</div>
<div class="card">
<h3><a href="database-app.html">Database Application</a></h3>
<p>Create a complete CRUD application using SQLite for persistent data storage.</p>
<div class="card-meta">
<span class="tag">sqlite</span>
<span class="tag">io</span>
</div>
</div>
<div class="card">
<h3><a href="template-rendering.html">Template Rendering</a></h3>
<p>Use Jinja templates to generate HTML pages, reports, and configuration files.</p>
<div class="card-meta">
<span class="tag">jinja</span>
<span class="tag">io</span>
</div>
</div>
<div class="card">
<h3><a href="cli-tool.html">Building a CLI Tool</a></h3>
<p>Create a command-line application with argument parsing, user input, and subprocess management.</p>
<div class="card-meta">
<span class="tag">os</span>
<span class="tag">subprocess</span>
</div>
</div>
<div class="card">
<h3><a href="web-server.html">Building a Web Server</a></h3>
<p>Build HTTP servers with routing, sessions, middleware, and REST APIs using the web module.</p>
<div class="card-meta">
<span class="tag">web</span>
<span class="tag">http</span>
</div>
</div>
</div>
<h2>Learning Path</h2>
<p>If you are new to Wren-CLI, we recommend following the tutorials in this order:</p>
<ol>
<li><strong>HTTP Client</strong> - Introduces async operations and JSON handling</li>
<li><strong>Database Application</strong> - Covers data persistence and file I/O</li>
<li><strong>Template Rendering</strong> - Learn the Jinja template system</li>
<li><strong>WebSocket Chat</strong> - Advanced async patterns with fibers</li>
<li><strong>CLI Tool</strong> - Bringing it all together in a real application</li>
<li><strong>Web Server</strong> - Build complete web applications with the web module</li>
</ol>
<h2>Prerequisites</h2>
<p>Before starting the tutorials, you should:</p>
<ul>
<li>Have Wren-CLI <a href="../getting-started/installation.html">installed</a></li>
<li>Understand the <a href="../language/index.html">basic syntax</a></li>
<li>Be familiar with <a href="../language/classes.html">classes</a> and <a href="../language/methods.html">methods</a></li>
</ul>
</article>
<footer class="page-footer">
<a href="../api/math.html" class="prev">math</a>
<a href="http-client.html" class="next">HTTP Client</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>

View File

@ -0,0 +1,172 @@
# retoor <retoor@molodetz.nl>
sections:
- title: "Getting Started"
directory: "getting-started"
pages:
- file: "index"
title: "Overview"
- file: "installation"
title: "Installation"
- file: "first-script"
title: "First Script"
- file: "repl"
title: "Using the REPL"
- title: "Playground"
directory: "."
pages:
- file: "playground"
title: "Try Wren"
- title: "Language"
directory: "language"
pages:
- file: "index"
title: "Syntax Overview"
- file: "classes"
title: "Classes"
- file: "methods"
title: "Methods"
- file: "control-flow"
title: "Control Flow"
- file: "fibers"
title: "Fibers"
- file: "modules"
title: "Modules"
- title: "API Reference"
directory: "api"
pages:
- file: "index"
title: "Overview"
- file: "string"
title: "String"
- file: "number"
title: "Num"
- file: "argparse"
title: "argparse"
- file: "base64"
title: "base64"
- file: "crypto"
title: "crypto"
- file: "dataset"
title: "dataset"
- file: "datetime"
title: "datetime"
- file: "dns"
title: "dns"
- file: "env"
title: "env"
- file: "faker"
title: "faker"
- file: "fswatch"
title: "fswatch"
- file: "html"
title: "html"
- file: "http"
title: "http"
- file: "io"
title: "io"
- file: "jinja"
title: "jinja"
- file: "json"
title: "json"
- file: "markdown"
title: "markdown"
- file: "math"
title: "math"
- file: "net"
title: "net"
- file: "os"
title: "os"
- file: "pathlib"
title: "pathlib"
- file: "regex"
title: "regex"
- file: "scheduler"
title: "scheduler"
- file: "signal"
title: "signal"
- file: "sqlite"
title: "sqlite"
- file: "subprocess"
title: "subprocess"
- file: "sysinfo"
title: "sysinfo"
- file: "tempfile"
title: "tempfile"
- file: "timer"
title: "timer"
- file: "tls"
title: "tls"
- file: "udp"
title: "udp"
- file: "uuid"
title: "uuid"
- file: "wdantic"
title: "wdantic"
- file: "web"
title: "web"
- file: "websocket"
title: "websocket"
- file: "yaml"
title: "yaml"
- title: "Tutorials"
directory: "tutorials"
pages:
- file: "index"
title: "Tutorial List"
- file: "http-client"
title: "HTTP Client"
- file: "websocket-chat"
title: "WebSocket Chat"
- file: "database-app"
title: "Database App"
- file: "template-rendering"
title: "Templates"
- file: "cli-tool"
title: "CLI Tool"
- file: "pexpect"
title: "Process Automation"
- file: "web-server"
title: "Web Server"
- title: "How-To Guides"
directory: "howto"
pages:
- file: "index"
title: "How-To List"
- file: "http-requests"
title: "HTTP Requests"
- file: "json-parsing"
title: "JSON Parsing"
- file: "regex-patterns"
title: "Regex Patterns"
- file: "file-operations"
title: "File Operations"
- file: "async-operations"
title: "Async Operations"
- file: "error-handling"
title: "Error Handling"
- title: "Contributing"
directory: "contributing"
pages:
- file: "index"
title: "Overview"
- file: "module-overview"
title: "Module Architecture"
- file: "pure-wren-module"
title: "Pure-Wren Modules"
- file: "c-backed-module"
title: "C-Backed Modules"
- file: "foreign-classes"
title: "Foreign Classes"
- file: "async-patterns"
title: "Async Patterns"
- file: "testing"
title: "Writing Tests"
- file: "documentation"
title: "Documentation"

View File

@ -0,0 +1,7 @@
# retoor <retoor@molodetz.nl>
name: "Wren-CLI"
version: "0.4.0"
description: "A complete reference for the Wren scripting language CLI"
author: "retoor <retoor@molodetz.nl>"
repo_url: "https://github.com/wren-lang/wren-cli"

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>argparse - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html" class="active">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>argparse</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "argparse" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "argparse"}] %}
{% set prev_page = {"url": "api/html.html", "title": "html"} %}
{% set next_page = {"url": "api/wdantic.html", "title": "wdantic"} %}
{% block article %}
<h1>argparse</h1>
<p>The <code>argparse</code> module provides command-line argument parsing with support for positional arguments, optional flags, type conversion, and help generation.</p>
@ -415,14 +297,4 @@ System.print(args["v"]) // 3</code></pre>
<div class="admonition-title">Note</div>
<p>Argument names starting with <code>-</code> are treated as optional flags. Names without a leading dash are positional arguments. Hyphens in argument names are converted to underscores in the result map.</p>
</div>
</article>
<footer class="page-footer">
<a href="html.html" class="prev">html</a>
<a href="wdantic.html" class="next">wdantic</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -0,0 +1,178 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "base64" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "base64"}] %}
{% set prev_page = {"url": "api/json.html", "title": "json"} %}
{% set next_page = {"url": "api/regex.html", "title": "regex"} %}
{% block article %}
<h1>base64</h1>
<p>The <code>base64</code> module provides Base64 encoding and decoding functionality, including URL-safe variants.</p>
<pre><code>import "base64" for Base64</code></pre>
<h2>Base64 Class</h2>
<div class="class-header">
<h3>Base64</h3>
<p>Base64 encoding and decoding utilities</p>
</div>
<h3>Static Methods</h3>
<div class="method-signature">
<span class="method-name">Base64.encode</span>(<span class="param">data</span>) &#8594; <span class="type">String</span>
</div>
<p>Encodes data to standard Base64.</p>
<ul class="param-list">
<li><span class="param-name">data</span> <span class="param-type">(String)</span> - Data to encode</li>
<li><span class="returns">Returns:</span> Base64-encoded string</li>
</ul>
<pre><code>var encoded = Base64.encode("Hello, World!")
System.print(encoded) // SGVsbG8sIFdvcmxkIQ==</code></pre>
<div class="method-signature">
<span class="method-name">Base64.decode</span>(<span class="param">data</span>) &#8594; <span class="type">String</span>
</div>
<p>Decodes a Base64-encoded string.</p>
<ul class="param-list">
<li><span class="param-name">data</span> <span class="param-type">(String)</span> - Base64 string to decode</li>
<li><span class="returns">Returns:</span> Decoded data as a string</li>
</ul>
<pre><code>var decoded = Base64.decode("SGVsbG8sIFdvcmxkIQ==")
System.print(decoded) // Hello, World!</code></pre>
<div class="method-signature">
<span class="method-name">Base64.encodeUrl</span>(<span class="param">data</span>) &#8594; <span class="type">String</span>
</div>
<p>Encodes data to URL-safe Base64. Replaces <code>+</code> with <code>-</code>, <code>/</code> with <code>_</code>, and removes padding.</p>
<ul class="param-list">
<li><span class="param-name">data</span> <span class="param-type">(String)</span> - Data to encode</li>
<li><span class="returns">Returns:</span> URL-safe Base64 string (no padding)</li>
</ul>
<pre><code>var encoded = Base64.encodeUrl("Hello, World!")
System.print(encoded) // SGVsbG8sIFdvcmxkIQ</code></pre>
<div class="method-signature">
<span class="method-name">Base64.decodeUrl</span>(<span class="param">data</span>) &#8594; <span class="type">String</span>
</div>
<p>Decodes a URL-safe Base64 string. Handles strings with or without padding.</p>
<ul class="param-list">
<li><span class="param-name">data</span> <span class="param-type">(String)</span> - URL-safe Base64 string to decode</li>
<li><span class="returns">Returns:</span> Decoded data as a string</li>
</ul>
<pre><code>var decoded = Base64.decodeUrl("SGVsbG8sIFdvcmxkIQ")
System.print(decoded) // Hello, World!</code></pre>
<h2>Encoding Comparison</h2>
<table>
<tr>
<th>Method</th>
<th>Alphabet</th>
<th>Padding</th>
<th>Use Case</th>
</tr>
<tr>
<td><code>encode</code></td>
<td>A-Z, a-z, 0-9, +, /</td>
<td>Yes (=)</td>
<td>General purpose, email, file storage</td>
</tr>
<tr>
<td><code>encodeUrl</code></td>
<td>A-Z, a-z, 0-9, -, _</td>
<td>No</td>
<td>URLs, filenames, JWT tokens</td>
</tr>
</table>
<h2>Examples</h2>
<h3>Basic Encoding and Decoding</h3>
<pre><code>import "base64" for Base64
var original = "The quick brown fox jumps over the lazy dog"
var encoded = Base64.encode(original)
System.print("Encoded: %(encoded)")
var decoded = Base64.decode(encoded)
System.print("Decoded: %(decoded)")
System.print("Match: %(original == decoded)")</code></pre>
<h3>Binary Data Encoding</h3>
<pre><code>import "base64" for Base64
var binaryData = String.fromCodePoint(0) +
String.fromCodePoint(1) +
String.fromCodePoint(255)
var encoded = Base64.encode(binaryData)
System.print("Encoded binary: %(encoded)")
var decoded = Base64.decode(encoded)
System.print("Byte 0: %(decoded.bytes[0])")
System.print("Byte 1: %(decoded.bytes[1])")
System.print("Byte 2: %(decoded.bytes[2])")</code></pre>
<h3>URL-Safe Encoding for Tokens</h3>
<pre><code>import "base64" for Base64
import "crypto" for Crypto, Hash
var data = "user:12345"
var token = Base64.encodeUrl(data)
System.print("Token: %(token)")
var decodedToken = Base64.decodeUrl(token)
System.print("Decoded: %(decodedToken)")</code></pre>
<h3>HTTP Basic Authentication</h3>
<pre><code>import "base64" for Base64
import "http" for Http
var username = "alice"
var password = "secret123"
var credentials = Base64.encode("%(username):%(password)")
var headers = {
"Authorization": "Basic %(credentials)"
}
var response = Http.get("https://api.example.com/protected", headers)
System.print(response.body)</code></pre>
<h3>Data URI Encoding</h3>
<pre><code>import "base64" for Base64
import "io" for File
var imageData = File.read("image.png")
var encoded = Base64.encode(imageData)
var dataUri = "data:image/png;base64,%(encoded)"
System.print(dataUri)</code></pre>
<h3>JWT-Style Token Parts</h3>
<pre><code>import "base64" for Base64
import "json" for Json
var header = {"alg": "HS256", "typ": "JWT"}
var payload = {"sub": "1234567890", "name": "John Doe"}
var headerB64 = Base64.encodeUrl(Json.stringify(header))
var payloadB64 = Base64.encodeUrl(Json.stringify(payload))
System.print("Header: %(headerB64)")
System.print("Payload: %(payloadB64)")</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>Base64 encoding increases data size by approximately 33%. A 3-byte input becomes 4 Base64 characters.</p>
</div>
<div class="admonition tip">
<div class="admonition-title">Tip</div>
<p>Use <code>encodeUrl</code> and <code>decodeUrl</code> when the encoded string will be used in URLs, query parameters, or filenames where <code>+</code>, <code>/</code>, and <code>=</code> characters may cause issues.</p>
</div>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>crypto - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html" class="active">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>crypto</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "crypto" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "crypto"}] %}
{% set prev_page = {"url": "api/jinja.html", "title": "jinja"} %}
{% set next_page = {"url": "api/os.html", "title": "os"} %}
{% block article %}
<h1>crypto</h1>
<p>The <code>crypto</code> module provides cryptographic functions including secure random number generation and hash algorithms.</p>
@ -341,14 +223,4 @@ System.print("Different input, different hash: %(Hash.toHex(hash1) != Hash.toHex
<div class="admonition-title">Tip</div>
<p>For password storage, always use a salt (random bytes prepended to the password) before hashing. Store the salt alongside the hash for verification.</p>
</div>
</article>
<footer class="page-footer">
<a href="jinja.html" class="prev">jinja</a>
<a href="os.html" class="next">os</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>dataset - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html" class="active">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>dataset</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "dataset" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "dataset"}] %}
{% set prev_page = {"url": "api/wdantic.html", "title": "wdantic"} %}
{% set next_page = {"url": "api/markdown.html", "title": "markdown"} %}
{% block article %}
<h1>dataset</h1>
<p>The <code>dataset</code> module provides a simple ORM-like interface for SQLite databases with automatic schema management. Tables and columns are created automatically as you insert data.</p>
@ -408,14 +290,4 @@ System.print(post["metadata"]) // {"author": "Alice", ...}</code></pre>
<div class="admonition-title">Warning</div>
<p>The <code>uid</code> field is the primary key. Do not use <code>id</code> as a field name. If you provide a <code>uid</code> during insert, it will be used instead of auto-generating one.</p>
</div>
</article>
<footer class="page-footer">
<a href="wdantic.html" class="prev">wdantic</a>
<a href="markdown.html" class="next">markdown</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>datetime - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html" class="active">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>datetime</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "datetime" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "datetime"}] %}
{% set prev_page = {"url": "api/sqlite.html", "title": "sqlite"} %}
{% set next_page = {"url": "api/timer.html", "title": "timer"} %}
{% block article %}
<h1>datetime</h1>
<p>The <code>datetime</code> module provides date and time handling with formatting, arithmetic, and duration support.</p>
@ -490,14 +372,4 @@ var deadline = now + Duration.fromDays(7)
if (now < deadline) {
System.print("Still have time!")
}</code></pre>
</article>
<footer class="page-footer">
<a href="sqlite.html" class="prev">sqlite</a>
<a href="timer.html" class="next">timer</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -0,0 +1,161 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "dns" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "dns"}] %}
{% set prev_page = {"url": "api/net.html", "title": "net"} %}
{% set next_page = {"url": "api/json.html", "title": "json"} %}
{% block article %}
<h1>dns</h1>
<p>The <code>dns</code> module provides DNS resolution functionality for looking up hostnames and resolving them to IP addresses.</p>
<pre><code>import "dns" for Dns</code></pre>
<h2>Dns Class</h2>
<div class="class-header">
<h3>Dns</h3>
<p>DNS resolution utilities</p>
</div>
<h3>Static Methods</h3>
<div class="method-signature">
<span class="method-name">Dns.lookup</span>(<span class="param">hostname</span>) &#8594; <span class="type">String</span>
</div>
<p>Resolves a hostname to an IP address. Uses the system's default address family preference.</p>
<ul class="param-list">
<li><span class="param-name">hostname</span> <span class="param-type">(String)</span> - Hostname to resolve</li>
<li><span class="returns">Returns:</span> IP address as a string</li>
</ul>
<pre><code>var ip = Dns.lookup("example.com")
System.print(ip) // 93.184.216.34</code></pre>
<div class="method-signature">
<span class="method-name">Dns.lookup</span>(<span class="param">hostname</span>, <span class="param">family</span>) &#8594; <span class="type">String</span>
</div>
<p>Resolves a hostname to an IP address with a specific address family.</p>
<ul class="param-list">
<li><span class="param-name">hostname</span> <span class="param-type">(String)</span> - Hostname to resolve</li>
<li><span class="param-name">family</span> <span class="param-type">(Num)</span> - Address family: 0 (any), 4 (IPv4), or 6 (IPv6)</li>
<li><span class="returns">Returns:</span> IP address as a string</li>
</ul>
<pre><code>var ipv4 = Dns.lookup("example.com", 4)
System.print(ipv4) // 93.184.216.34
var ipv6 = Dns.lookup("example.com", 6)
System.print(ipv6) // 2606:2800:220:1:248:1893:25c8:1946</code></pre>
<h3>Address Family Values</h3>
<table>
<tr>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td><code>0</code></td>
<td>Any (system default, typically prefers IPv4)</td>
</tr>
<tr>
<td><code>4</code></td>
<td>IPv4 only</td>
</tr>
<tr>
<td><code>6</code></td>
<td>IPv6 only</td>
</tr>
</table>
<h2>Examples</h2>
<h3>Basic DNS Lookup</h3>
<pre><code>import "dns" for Dns
var domains = ["example.com", "google.com", "github.com"]
for (domain in domains) {
var ip = Dns.lookup(domain)
System.print("%(domain) -> %(ip)")
}</code></pre>
<h3>IPv4 vs IPv6</h3>
<pre><code>import "dns" for Dns
var hostname = "google.com"
var ipv4 = Dns.lookup(hostname, 4)
System.print("IPv4: %(ipv4)")
var fiber = Fiber.new {
return Dns.lookup(hostname, 6)
}
var result = fiber.try()
if (fiber.error != null) {
System.print("IPv6: Not available")
} else {
System.print("IPv6: %(result)")
}</code></pre>
<h3>Using with Socket Connection</h3>
<pre><code>import "dns" for Dns
import "net" for Socket
var hostname = "httpbin.org"
var ip = Dns.lookup(hostname, 4)
System.print("Connecting to %(hostname) (%(ip))")
var socket = Socket.connect(ip, 80)
socket.write("GET /ip HTTP/1.1\r\nHost: %(hostname)\r\nConnection: close\r\n\r\n")
var response = ""
while (true) {
var data = socket.read()
if (data == null) break
response = response + data
}
socket.close()
System.print(response)</code></pre>
<h3>Using with TLS Connection</h3>
<pre><code>import "dns" for Dns
import "tls" for TlsSocket
var hostname = "example.com"
var ip = Dns.lookup(hostname, 4)
var socket = TlsSocket.connect(ip, 443, hostname)
socket.write("GET / HTTP/1.1\r\nHost: %(hostname)\r\nConnection: close\r\n\r\n")
var response = socket.read()
System.print(response)
socket.close()</code></pre>
<h3>Error Handling</h3>
<pre><code>import "dns" for Dns
var fiber = Fiber.new {
return Dns.lookup("nonexistent.invalid.domain")
}
var result = fiber.try()
if (fiber.error != null) {
System.print("DNS lookup failed: %(fiber.error)")
} else {
System.print("Resolved to: %(result)")
}</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>DNS lookups are asynchronous operations that use libuv's thread pool. The calling fiber will suspend until the lookup completes.</p>
</div>
<div class="admonition warning">
<div class="admonition-title">Warning</div>
<p>The hostname must be a string. Passing a non-string value will abort the fiber with an error. Similarly, the family parameter must be 0, 4, or 6.</p>
</div>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>env - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html" class="active">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>env</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "env" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "env"}] %}
{% set prev_page = {"url": "api/dns.html", "title": "dns"} %}
{% set next_page = {"url": "api/faker.html", "title": "faker"} %}
{% block article %}
<h1>env</h1>
<p>The <code>env</code> module provides access to environment variables for reading, writing, and deleting values.</p>
@ -323,14 +205,4 @@ if (dbUrl != null) {
<div class="admonition-title">Warning</div>
<p>Never log or print sensitive environment variables like API keys, passwords, or secrets. Use them directly in your application without exposing their values.</p>
</div>
</article>
<footer class="page-footer">
<a href="dns.html" class="prev">dns</a>
<a href="fswatch.html" class="next">fswatch</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -0,0 +1,814 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "faker" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "faker"}] %}
{% set prev_page = {"url": "api/env.html", "title": "env"} %}
{% set next_page = {"url": "api/fswatch.html", "title": "fswatch"} %}
{% block article %}
<h1>faker</h1>
<p>The <code>faker</code> module generates realistic fake data for testing, seeding databases, and prototyping. It provides deterministic output when seeded for reproducible test cases.</p>
<pre><code>import "faker" for Faker</code></pre>
<div class="toc">
<h4>On This Page</h4>
<ul>
<li><a href="#seeding">Seeding &amp; Random</a></li>
<li><a href="#format-helpers">Format Helpers</a></li>
<li><a href="#person">Person &amp; Names</a></li>
<li><a href="#address">Address &amp; Location</a></li>
<li><a href="#internet">Internet &amp; Network</a></li>
<li><a href="#datetime">Date &amp; Time</a></li>
<li><a href="#text">Text &amp; Lorem</a></li>
<li><a href="#colors">Colors</a></li>
<li><a href="#company">Company &amp; Job</a></li>
<li><a href="#commerce">Commerce &amp; Products</a></li>
<li><a href="#banking">Banking &amp; Finance</a></li>
<li><a href="#files">Files &amp; Hashes</a></li>
<li><a href="#utilities">Utilities</a></li>
</ul>
</div>
<h2>Faker Class</h2>
<div class="class-header">
<h3>Faker</h3>
<p>Generates realistic fake data across many categories</p>
</div>
<h2 id="seeding">Seeding &amp; Random</h2>
<div class="method-signature">
<span class="method-name">Faker.seed</span>(<span class="param">value</span>)
</div>
<p>Sets the random seed for deterministic output. Use the same seed to generate identical sequences.</p>
<ul class="param-list">
<li><span class="param-name">value</span> <span class="param-type">(Num)</span> - Integer seed value</li>
</ul>
<pre><code>Faker.seed(12345)
System.print(Faker.name()) // Always produces the same name with this seed</code></pre>
<div class="method-signature">
<span class="method-name">Faker.reset</span>()
</div>
<p>Resets to unseeded mode, using cryptographically random values.</p>
<pre><code>Faker.reset()
System.print(Faker.name()) // Now produces random names</code></pre>
<div class="method-signature">
<span class="method-name">Faker.randomElement</span>(<span class="param">list</span>) &rarr; <span class="type">Any</span>
</div>
<p>Returns a random element from a list.</p>
<pre><code>var colors = ["red", "green", "blue"]
System.print(Faker.randomElement(colors))</code></pre>
<div class="method-signature">
<span class="method-name">Faker.randomElements</span>(<span class="param">list</span>, <span class="param">count</span>) &rarr; <span class="type">List</span>
</div>
<p>Returns multiple random elements from a list (with possible duplicates).</p>
<pre><code>var picks = Faker.randomElements(["a", "b", "c", "d"], 3)
System.print(picks) // e.g., ["b", "a", "b"]</code></pre>
<div class="method-signature">
<span class="method-name">Faker.randomInt</span>(<span class="param">min</span>, <span class="param">max</span>) &rarr; <span class="type">Num</span>
</div>
<p>Returns a random integer between min and max (inclusive).</p>
<pre><code>var age = Faker.randomInt(18, 65)
System.print(age) // e.g., 42</code></pre>
<div class="method-signature">
<span class="method-name">Faker.randomFloat</span>(<span class="param">min</span>, <span class="param">max</span>) &rarr; <span class="type">Num</span>
</div>
<p>Returns a random float between min and max.</p>
<pre><code>var temp = Faker.randomFloat(20, 30)
System.print(temp) // e.g., 24.7831...</code></pre>
<div class="method-signature">
<span class="method-name">Faker.randomFloat</span>(<span class="param">min</span>, <span class="param">max</span>, <span class="param">precision</span>) &rarr; <span class="type">Num</span>
</div>
<p>Returns a random float with specified decimal precision.</p>
<pre><code>var price = Faker.randomFloat(10, 100, 2)
System.print(price) // e.g., 47.83</code></pre>
<div class="method-signature">
<span class="method-name">Faker.boolean</span>() &rarr; <span class="type">Bool</span>
</div>
<p>Returns a random boolean. Alias: <code>bool()</code>.</p>
<pre><code>var isActive = Faker.boolean()
System.print(isActive) // true or false</code></pre>
<h2 id="format-helpers">Format Helpers</h2>
<div class="method-signature">
<span class="method-name">Faker.numerify</span>(<span class="param">format</span>) &rarr; <span class="type">String</span>
</div>
<p>Replaces <code>#</code> characters with random digits.</p>
<pre><code>System.print(Faker.numerify("###-###-####")) // e.g., "415-555-2938"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.letterify</span>(<span class="param">format</span>) &rarr; <span class="type">String</span>
</div>
<p>Replaces <code>?</code> characters with random lowercase letters.</p>
<pre><code>System.print(Faker.letterify("???-????")) // e.g., "abc-defg"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.bothify</span>(<span class="param">format</span>) &rarr; <span class="type">String</span>
</div>
<p>Replaces both <code>#</code> with digits and <code>?</code> with letters.</p>
<pre><code>System.print(Faker.bothify("??-###")) // e.g., "ab-123"</code></pre>
<h2 id="person">Person &amp; Names</h2>
<div class="method-signature">
<span class="method-name">Faker.firstName</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random first name. Gender-specific variants: <code>firstNameMale()</code>, <code>firstNameFemale()</code>.</p>
<pre><code>System.print(Faker.firstName()) // e.g., "Emily"
System.print(Faker.firstNameMale()) // e.g., "James"
System.print(Faker.firstNameFemale()) // e.g., "Sarah"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.lastName</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random last name.</p>
<pre><code>System.print(Faker.lastName()) // e.g., "Johnson"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.name</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a full name (first + last). Variants: <code>nameMale()</code>, <code>nameFemale()</code>.</p>
<pre><code>System.print(Faker.name()) // e.g., "Emily Johnson"
System.print(Faker.nameMale()) // e.g., "James Smith"
System.print(Faker.nameFemale()) // e.g., "Sarah Williams"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.prefix</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a name prefix (Mr., Mrs., Ms., Miss, Dr.). Alias: <code>namePrefix()</code>.</p>
<pre><code>System.print(Faker.prefix()) // e.g., "Dr."</code></pre>
<div class="method-signature">
<span class="method-name">Faker.suffix</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a name suffix (Jr., Sr., MD, PhD, etc.). Alias: <code>nameSuffix()</code>.</p>
<pre><code>System.print(Faker.suffix()) // e.g., "Jr."</code></pre>
<div class="method-signature">
<span class="method-name">Faker.gender</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns "Male" or "Female". Alias: <code>sex()</code>.</p>
<pre><code>System.print(Faker.gender()) // "Male" or "Female"</code></pre>
<h2 id="address">Address &amp; Location</h2>
<div class="method-signature">
<span class="method-name">Faker.address</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a full US-style address.</p>
<pre><code>System.print(Faker.address()) // e.g., "1234 Oak Street, Denver, CO 80201"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.streetAddress</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a street address (number + street name).</p>
<pre><code>System.print(Faker.streetAddress()) // e.g., "1234 Oak Street"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.streetName</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a street name with suffix.</p>
<pre><code>System.print(Faker.streetName()) // e.g., "Oak Boulevard"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.buildingNumber</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random building number (1-9999).</p>
<pre><code>System.print(Faker.buildingNumber()) // e.g., "4521"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.city</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a US city name.</p>
<pre><code>System.print(Faker.city()) // e.g., "Portland"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.state</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a US state name. Aliases: <code>stateFull()</code>, <code>stateName()</code>.</p>
<pre><code>System.print(Faker.state()) // e.g., "California"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.stateAbbr</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a US state abbreviation.</p>
<pre><code>System.print(Faker.stateAbbr()) // e.g., "CA"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.country</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a country name. Alias: <code>countryName()</code>.</p>
<pre><code>System.print(Faker.country()) // e.g., "Germany"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.countryCode</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a two-letter country code.</p>
<pre><code>System.print(Faker.countryCode()) // e.g., "DE"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.zipCode</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a 5-digit US ZIP code. Alias: <code>postcode()</code>.</p>
<pre><code>System.print(Faker.zipCode()) // e.g., "90210"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.latitude</span>() &rarr; <span class="type">Num</span>
</div>
<p>Returns a random latitude (-90 to 90) with 6 decimal places.</p>
<pre><code>System.print(Faker.latitude()) // e.g., 40.712776</code></pre>
<div class="method-signature">
<span class="method-name">Faker.latitude</span>(<span class="param">min</span>, <span class="param">max</span>) &rarr; <span class="type">Num</span>
</div>
<p>Returns a latitude within a specific range.</p>
<pre><code>System.print(Faker.latitude(30, 50)) // e.g., 42.358429</code></pre>
<div class="method-signature">
<span class="method-name">Faker.longitude</span>() &rarr; <span class="type">Num</span>
</div>
<p>Returns a random longitude (-180 to 180) with 6 decimal places.</p>
<pre><code>System.print(Faker.longitude()) // e.g., -74.005974</code></pre>
<div class="method-signature">
<span class="method-name">Faker.longitude</span>(<span class="param">min</span>, <span class="param">max</span>) &rarr; <span class="type">Num</span>
</div>
<p>Returns a longitude within a specific range.</p>
<pre><code>System.print(Faker.longitude(-125, -65)) // e.g., -87.629799</code></pre>
<h2 id="internet">Internet &amp; Network</h2>
<div class="method-signature">
<span class="method-name">Faker.email</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random email address.</p>
<pre><code>System.print(Faker.email()) // e.g., "john.smith42@gmail.com"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.exampleEmail</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns an email using example.com/org/net domains (safe for testing).</p>
<pre><code>System.print(Faker.exampleEmail()) // e.g., "alice_jones@example.org"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.username</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random username in various formats.</p>
<pre><code>System.print(Faker.username()) // e.g., "john.smith", "emily_42"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.password</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a 12-character random password.</p>
<pre><code>System.print(Faker.password()) // e.g., "aB3$kLm9@pQr"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.password</span>(<span class="param">length</span>) &rarr; <span class="type">String</span>
</div>
<p>Returns a password of specified length.</p>
<pre><code>System.print(Faker.password(20)) // 20-character password</code></pre>
<div class="method-signature">
<span class="method-name">Faker.url</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random URL.</p>
<pre><code>System.print(Faker.url()) // e.g., "https://smith.io"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.domainName</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a domain name.</p>
<pre><code>System.print(Faker.domainName()) // e.g., "johnson.com"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.domainWord</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a domain word (without TLD).</p>
<pre><code>System.print(Faker.domainWord()) // e.g., "smith"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.tld</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a top-level domain. Alias: <code>topLevelDomain()</code>.</p>
<pre><code>System.print(Faker.tld()) // e.g., "com", "io", "org"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.protocol</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns "http" or "https".</p>
<pre><code>System.print(Faker.protocol()) // "http" or "https"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.ipv4</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random IPv4 address.</p>
<pre><code>System.print(Faker.ipv4()) // e.g., "192.168.45.123"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.ipv6</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random IPv6 address.</p>
<pre><code>System.print(Faker.ipv6()) // e.g., "2001:0db8:85a3:0000:0000:8a2e:0370:7334"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.macAddress</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random MAC address.</p>
<pre><code>System.print(Faker.macAddress()) // e.g., "00:1a:2b:3c:4d:5e"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.port</span>() &rarr; <span class="type">Num</span>
</div>
<p>Returns a random port number (1-65535).</p>
<pre><code>System.print(Faker.port()) // e.g., 8080</code></pre>
<div class="method-signature">
<span class="method-name">Faker.hostname</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a hostname with subdomain.</p>
<pre><code>System.print(Faker.hostname()) // e.g., "server-42.company.com"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.httpMethod</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random HTTP method.</p>
<pre><code>System.print(Faker.httpMethod()) // "GET", "POST", "PUT", etc.</code></pre>
<div class="method-signature">
<span class="method-name">Faker.httpStatusCode</span>() &rarr; <span class="type">Num</span>
</div>
<p>Returns a common HTTP status code.</p>
<pre><code>System.print(Faker.httpStatusCode()) // 200, 404, 500, etc.</code></pre>
<div class="method-signature">
<span class="method-name">Faker.userAgent</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a realistic browser user agent string.</p>
<pre><code>System.print(Faker.userAgent()) // e.g., "Mozilla/5.0 (Windows NT 10.0..."</code></pre>
<h2 id="datetime">Date &amp; Time</h2>
<div class="method-signature">
<span class="method-name">Faker.date</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random date within the past 10 years in YYYY-MM-DD format.</p>
<pre><code>System.print(Faker.date()) // e.g., "2021-07-15"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.dateTime</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random datetime within the past 10 years in ISO 8601 format.</p>
<pre><code>System.print(Faker.dateTime()) // e.g., "2022-03-14T09:26:53Z"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.pastDate</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a date within the past year. Accepts optional years parameter.</p>
<pre><code>System.print(Faker.pastDate()) // Within past year
System.print(Faker.pastDate(5)) // Within past 5 years</code></pre>
<div class="method-signature">
<span class="method-name">Faker.futureDate</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a date within the next year. Accepts optional years parameter.</p>
<pre><code>System.print(Faker.futureDate()) // Within next year
System.print(Faker.futureDate(2)) // Within next 2 years</code></pre>
<div class="method-signature">
<span class="method-name">Faker.dateBetween</span>(<span class="param">start</span>, <span class="param">end</span>) &rarr; <span class="type">String</span>
</div>
<p>Returns a random date between two DateTime objects.</p>
<pre><code>import "datetime" for DateTime, Duration
var start = DateTime.now() - Duration.fromDays(30)
var end = DateTime.now()
System.print(Faker.dateBetween(start, end))</code></pre>
<div class="method-signature">
<span class="method-name">Faker.dateOfBirth</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a birth date for someone aged 18-80. Accepts optional min/max age.</p>
<pre><code>System.print(Faker.dateOfBirth()) // Age 18-80
System.print(Faker.dateOfBirth(21, 35)) // Age 21-35</code></pre>
<div class="method-signature">
<span class="method-name">Faker.year</span>() &rarr; <span class="type">Num</span>
</div>
<p>Returns a random year (1950-2025).</p>
<pre><code>System.print(Faker.year()) // e.g., 1987</code></pre>
<div class="method-signature">
<span class="method-name">Faker.month</span>() &rarr; <span class="type">Num</span>
</div>
<p>Returns a random month number (1-12).</p>
<pre><code>System.print(Faker.month()) // e.g., 7</code></pre>
<div class="method-signature">
<span class="method-name">Faker.monthName</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a month name.</p>
<pre><code>System.print(Faker.monthName()) // e.g., "July"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.dayOfWeek</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a day of the week.</p>
<pre><code>System.print(Faker.dayOfWeek()) // e.g., "Wednesday"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.dayOfMonth</span>() &rarr; <span class="type">Num</span>
</div>
<p>Returns a random day (1-28).</p>
<pre><code>System.print(Faker.dayOfMonth()) // e.g., 15</code></pre>
<div class="method-signature">
<span class="method-name">Faker.time</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random time in HH:MM:SS format.</p>
<pre><code>System.print(Faker.time()) // e.g., "14:32:07"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.hour</span>() &rarr; <span class="type">Num</span>
</div>
<p>Returns a random hour (0-23). Related: <code>minute()</code>, <code>second()</code>, <code>amPm()</code>.</p>
<pre><code>System.print(Faker.hour()) // e.g., 14
System.print(Faker.minute()) // e.g., 32
System.print(Faker.second()) // e.g., 45
System.print(Faker.amPm()) // "AM" or "PM"</code></pre>
<h2 id="text">Text &amp; Lorem</h2>
<div class="method-signature">
<span class="method-name">Faker.word</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random lorem ipsum word.</p>
<pre><code>System.print(Faker.word()) // e.g., "consectetur"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.words</span>(<span class="param">count</span>) &rarr; <span class="type">List</span>
</div>
<p>Returns a list of random words.</p>
<pre><code>System.print(Faker.words(5)) // ["lorem", "ipsum", "dolor", "sit", "amet"]</code></pre>
<div class="method-signature">
<span class="method-name">Faker.sentence</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a sentence (5-12 words). Accepts optional word count.</p>
<pre><code>System.print(Faker.sentence()) // Random length
System.print(Faker.sentence(8)) // Exactly 8 words</code></pre>
<div class="method-signature">
<span class="method-name">Faker.sentences</span>(<span class="param">count</span>) &rarr; <span class="type">String</span>
</div>
<p>Returns multiple sentences joined with spaces.</p>
<pre><code>System.print(Faker.sentences(3)) // Three sentences</code></pre>
<div class="method-signature">
<span class="method-name">Faker.paragraph</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a paragraph (3-6 sentences). Accepts optional sentence count.</p>
<pre><code>System.print(Faker.paragraph()) // Random length
System.print(Faker.paragraph(5)) // Exactly 5 sentences</code></pre>
<div class="method-signature">
<span class="method-name">Faker.paragraphs</span>(<span class="param">count</span>) &rarr; <span class="type">String</span>
</div>
<p>Returns multiple paragraphs separated by double newlines.</p>
<pre><code>System.print(Faker.paragraphs(3)) // Three paragraphs</code></pre>
<div class="method-signature">
<span class="method-name">Faker.text</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns approximately 200 characters of text. Accepts optional max length.</p>
<pre><code>System.print(Faker.text()) // ~200 characters
System.print(Faker.text(500)) // ~500 characters</code></pre>
<div class="method-signature">
<span class="method-name">Faker.slug</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a URL-friendly slug (3 words). Accepts optional word count.</p>
<pre><code>System.print(Faker.slug()) // e.g., "lorem-ipsum-dolor"
System.print(Faker.slug(5)) // e.g., "lorem-ipsum-dolor-sit-amet"</code></pre>
<h2 id="colors">Colors</h2>
<div class="method-signature">
<span class="method-name">Faker.colorName</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a color name.</p>
<pre><code>System.print(Faker.colorName()) // e.g., "Crimson"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.hexColor</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a hex color code.</p>
<pre><code>System.print(Faker.hexColor()) // e.g., "#a3c2f0"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.rgbColor</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns an RGB color string. Alias: <code>rgb()</code>.</p>
<pre><code>System.print(Faker.rgbColor()) // e.g., "rgb(163, 194, 240)"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.rgbaCssColor</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns an RGBA color string with random alpha.</p>
<pre><code>System.print(Faker.rgbaCssColor()) // e.g., "rgba(163, 194, 240, 0.75)"</code></pre>
<h2 id="company">Company &amp; Job</h2>
<div class="method-signature">
<span class="method-name">Faker.company</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a company name. Alias: <code>companyName()</code>.</p>
<pre><code>System.print(Faker.company()) // e.g., "Smith Industries"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.companySuffix</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a company suffix.</p>
<pre><code>System.print(Faker.companySuffix()) // e.g., "LLC", "Inc.", "Corp."</code></pre>
<div class="method-signature">
<span class="method-name">Faker.job</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a job title. Alias: <code>jobTitle()</code>.</p>
<pre><code>System.print(Faker.job()) // e.g., "Software Engineer"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.jobDescriptor</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a job level descriptor.</p>
<pre><code>System.print(Faker.jobDescriptor()) // e.g., "Senior", "Lead", "Principal"</code></pre>
<h2 id="commerce">Commerce &amp; Products</h2>
<div class="method-signature">
<span class="method-name">Faker.product</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a product name. Alias: <code>productName()</code>.</p>
<pre><code>System.print(Faker.product()) // e.g., "Elegant Steel Chair"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.productCategory</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a product category.</p>
<pre><code>System.print(Faker.productCategory()) // e.g., "Electronics"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.price</span>() &rarr; <span class="type">Num</span>
</div>
<p>Returns a price (1-1000) with 2 decimal places. Accepts optional min/max.</p>
<pre><code>System.print(Faker.price()) // e.g., 49.99
System.print(Faker.price(10, 50)) // e.g., 24.95</code></pre>
<div class="method-signature">
<span class="method-name">Faker.currency</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a currency code.</p>
<pre><code>System.print(Faker.currency()) // e.g., "USD", "EUR", "GBP"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.currencyName</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a currency name.</p>
<pre><code>System.print(Faker.currencyName()) // e.g., "US Dollar"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.currencySymbol</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a currency symbol.</p>
<pre><code>System.print(Faker.currencySymbol()) // e.g., "$", "€", "£"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.creditCardType</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a credit card type.</p>
<pre><code>System.print(Faker.creditCardType()) // e.g., "Visa", "Mastercard"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.creditCardNumber</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a formatted credit card number.</p>
<pre><code>System.print(Faker.creditCardNumber()) // e.g., "4123-4567-8901-234"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.creditCardCVV</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a 3-digit CVV code.</p>
<pre><code>System.print(Faker.creditCardCVV()) // e.g., "123"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.creditCardExpiryDate</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns an expiry date in MM/YY format.</p>
<pre><code>System.print(Faker.creditCardExpiryDate()) // e.g., "09/27"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.phoneNumber</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a US-format phone number. Alias: <code>phone()</code>.</p>
<pre><code>System.print(Faker.phoneNumber()) // e.g., "(415) 555-1234"</code></pre>
<h2 id="banking">Banking &amp; Finance</h2>
<div class="method-signature">
<span class="method-name">Faker.iban</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns an IBAN (International Bank Account Number).</p>
<pre><code>System.print(Faker.iban()) // e.g., "DE89370400440532013000"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.accountNumber</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a 10-digit account number. Accepts optional length.</p>
<pre><code>System.print(Faker.accountNumber()) // 10 digits
System.print(Faker.accountNumber(12)) // 12 digits</code></pre>
<div class="method-signature">
<span class="method-name">Faker.routingNumber</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a 9-digit routing number.</p>
<pre><code>System.print(Faker.routingNumber()) // e.g., "123456789"</code></pre>
<h2 id="files">Files &amp; Hashes</h2>
<div class="method-signature">
<span class="method-name">Faker.fileName</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a file name with extension.</p>
<pre><code>System.print(Faker.fileName()) // e.g., "document.pdf"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.fileExtension</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a file extension.</p>
<pre><code>System.print(Faker.fileExtension()) // e.g., "pdf", "jpg", "txt"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.mimeType</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a MIME type.</p>
<pre><code>System.print(Faker.mimeType()) // e.g., "application/json"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.semver</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a semantic version string.</p>
<pre><code>System.print(Faker.semver()) // e.g., "2.14.3"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.uuid</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a UUID v4.</p>
<pre><code>System.print(Faker.uuid()) // e.g., "550e8400-e29b-41d4-a716-446655440000"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.md5</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns an MD5 hash string.</p>
<pre><code>System.print(Faker.md5()) // 32-character hex string</code></pre>
<div class="method-signature">
<span class="method-name">Faker.sha1</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a SHA-1 hash string.</p>
<pre><code>System.print(Faker.sha1()) // 40-character hex string</code></pre>
<div class="method-signature">
<span class="method-name">Faker.sha256</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a SHA-256 hash string.</p>
<pre><code>System.print(Faker.sha256()) // 64-character hex string</code></pre>
<h2 id="utilities">Utilities</h2>
<div class="method-signature">
<span class="method-name">Faker.digit</span>() &rarr; <span class="type">Num</span>
</div>
<p>Returns a random digit (0-9). Alias: <code>randomDigit()</code>.</p>
<pre><code>System.print(Faker.digit()) // 0-9</code></pre>
<div class="method-signature">
<span class="method-name">Faker.digits</span>(<span class="param">count</span>) &rarr; <span class="type">List</span>
</div>
<p>Returns a list of random digits.</p>
<pre><code>System.print(Faker.digits(4)) // e.g., [1, 4, 7, 2]</code></pre>
<div class="method-signature">
<span class="method-name">Faker.letter</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns a random lowercase letter.</p>
<pre><code>System.print(Faker.letter()) // e.g., "k"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.letters</span>(<span class="param">count</span>) &rarr; <span class="type">String</span>
</div>
<p>Returns a string of random lowercase letters.</p>
<pre><code>System.print(Faker.letters(6)) // e.g., "xkjmvq"</code></pre>
<div class="method-signature">
<span class="method-name">Faker.shuffle</span>(<span class="param">list</span>) &rarr; <span class="type">List</span>
</div>
<p>Returns a shuffled copy of the list.</p>
<pre><code>var nums = [1, 2, 3, 4, 5]
System.print(Faker.shuffle(nums)) // e.g., [3, 1, 5, 2, 4]</code></pre>
<div class="method-signature">
<span class="method-name">Faker.profile</span>() &rarr; <span class="type">Map</span>
</div>
<p>Returns a complete user profile with username, name, email, address, phone, job, company, and birthdate.</p>
<pre><code>var user = Faker.profile()
System.print(user["name"])
System.print(user["email"])
System.print(user["company"])</code></pre>
<div class="method-signature">
<span class="method-name">Faker.simpleProfile</span>() &rarr; <span class="type">Map</span>
</div>
<p>Returns a basic profile with username, name, email, and address.</p>
<pre><code>var user = Faker.simpleProfile()
System.print(user["name"])
System.print(user["email"])</code></pre>
<div class="method-signature">
<span class="method-name">Faker.locale</span>() &rarr; <span class="type">String</span>
</div>
<p>Returns the current locale (always "en_US").</p>
<pre><code>System.print(Faker.locale()) // "en_US"</code></pre>
<h2>Examples</h2>
<h3>Seeding for Reproducible Tests</h3>
<pre><code>import "faker" for Faker
Faker.seed(42)
var user1 = Faker.name()
var user2 = Faker.name()
Faker.seed(42)
System.print(Faker.name() == user1) // true
System.print(Faker.name() == user2) // true</code></pre>
<h3>Generating Test Users</h3>
<pre><code>import "faker" for Faker
import "json" for Json
var users = []
for (i in 0...5) {
users.add({
"id": Faker.uuid(),
"name": Faker.name(),
"email": Faker.email(),
"age": Faker.randomInt(18, 65),
"active": Faker.boolean()
})
}
System.print(Json.stringify(users, 2))</code></pre>
<h3>Creating Product Catalog</h3>
<pre><code>import "faker" for Faker
for (i in 0...3) {
System.print("Product: %(Faker.product())")
System.print("Category: %(Faker.productCategory())")
System.print("Price: %(Faker.currencySymbol())%(Faker.price())")
System.print("---")
}</code></pre>
<h3>Generating Addresses</h3>
<pre><code>import "faker" for Faker
for (i in 0...3) {
System.print(Faker.address())
System.print(" Lat: %(Faker.latitude())")
System.print(" Lng: %(Faker.longitude())")
System.print("")
}</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>When unseeded, Faker uses cryptographically secure random numbers from the <code>crypto</code> module. When seeded, it uses a deterministic linear congruential generator for reproducibility.</p>
</div>
<div class="admonition tip">
<div class="admonition-title">Tip</div>
<p>Use seeding in tests to ensure consistent, reproducible test data. Call <code>Faker.reset()</code> to return to random mode for production use.</p>
</div>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>fswatch - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html" class="active">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>fswatch</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "fswatch" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "fswatch"}] %}
{% set prev_page = {"url": "api/faker.html", "title": "faker"} %}
{% set next_page = {"url": "api/html.html", "title": "html"} %}
{% block article %}
<h1>fswatch</h1>
<p>The <code>fswatch</code> module provides file system watching capabilities, allowing scripts to monitor files and directories for changes in real-time. Built on libuv's filesystem events.</p>
@ -370,14 +252,4 @@ System.print("Watching ./data (Ctrl+C to stop)")</code></pre>
<div class="admonition-title">Warning</div>
<p>Watching a large directory tree may consume significant system resources. Consider watching specific subdirectories when possible.</p>
</div>
</article>
<footer class="page-footer">
<a href="env.html" class="prev">env</a>
<a href="html.html" class="next">html</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>html - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html" class="active">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>html</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "html" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "html"}] %}
{% set prev_page = {"url": "api/fswatch.html", "title": "fswatch"} %}
{% set next_page = {"url": "api/http.html", "title": "http"} %}
{% block article %}
<h1>html</h1>
<p>The <code>html</code> module provides utilities for HTML and URL encoding/decoding, slug generation, and query string handling.</p>
@ -300,14 +182,4 @@ for (key in params.keys) {
<div class="admonition-title">Warning</div>
<p>Always use <code>Html.quote()</code> when inserting user-provided content into HTML to prevent cross-site scripting (XSS) attacks.</p>
</div>
</article>
<footer class="page-footer">
<a href="fswatch.html" class="prev">fswatch</a>
<a href="http.html" class="next">http</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>http - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html" class="active">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>http</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "http" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "http"}] %}
{% set prev_page = {"url": "api/index.html", "title": "API Overview"} %}
{% set next_page = {"url": "api/websocket.html", "title": "websocket"} %}
{% block article %}
<h1>http</h1>
<p>The <code>http</code> module provides an HTTP client for making requests to web servers. It supports both HTTP and HTTPS, all common HTTP methods, custom headers, and JSON handling.</p>
@ -444,14 +326,4 @@ for (entry in response.headers) {
<div class="admonition-title">Tip</div>
<p>When posting a Map or List, the module automatically sets <code>Content-Type: application/json</code> and JSON-encodes the body. For other content types, pass a string body and set the Content-Type header explicitly.</p>
</div>
</article>
<footer class="page-footer">
<a href="index.html" class="prev">API Overview</a>
<a href="websocket.html" class="next">websocket</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,128 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Reference - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html" class="active">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<span>API Reference</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "API Reference" %}
{% set breadcrumb = [{"title": "API Reference"}] %}
{% set prev_page = {"url": "language/modules.html", "title": "Modules"} %}
{% set next_page = {"url": "api/http.html", "title": "http"} %}
{% block article %}
<h1>API Reference</h1>
<p>Wren-CLI provides 32 built-in modules covering networking, file I/O, data processing, system operations, and more. All modules are imported using the <code>import</code> statement.</p>
@ -462,14 +346,4 @@ import "io" for File</code></pre>
<td>Web framework</td>
</tr>
</table>
</article>
<footer class="page-footer">
<a href="../language/modules.html" class="prev">Modules</a>
<a href="http.html" class="next">http</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>io - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html" class="active">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>io</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "io" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "io"}] %}
{% set prev_page = {"url": "api/timer.html", "title": "timer"} %}
{% set next_page = {"url": "api/pathlib.html", "title": "pathlib"} %}
{% block article %}
<h1>io</h1>
<p>The <code>io</code> module provides file and directory operations, as well as stdin/stdout handling.</p>
@ -405,14 +287,4 @@ backup.call("important.txt")</code></pre>
<div class="admonition-title">Note</div>
<p>File operations are synchronous but use libuv internally for async I/O. The fiber suspends during I/O operations.</p>
</div>
</article>
<footer class="page-footer">
<a href="timer.html" class="prev">timer</a>
<a href="pathlib.html" class="next">pathlib</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,135 +1,18 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jinja - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html" class="active">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>jinja</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "jinja" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "jinja"}] %}
{% set prev_page = {"url": "api/regex.html", "title": "regex"} %}
{% set next_page = {"url": "api/crypto.html", "title": "crypto"} %}
{% block article %}
{% raw %}
<h1>jinja</h1>
<p>The <code>jinja</code> module provides a Jinja2-compatible template engine for Wren. It supports variable interpolation, filters, control structures, template inheritance, macros, and more.</p>
<pre><code>import "jinja" for Environment, DictLoader, FileSystemLoader, Template</code></pre>
<pre><code>import "jinja" for Environment, DictLoader, FileSystemLoader, ChoiceLoader, Template</code></pre>
<div class="toc">
<h4>On This Page</h4>
@ -137,6 +20,7 @@
<li><a href="#environment-class">Environment Class</a></li>
<li><a href="#dictloader-class">DictLoader Class</a></li>
<li><a href="#filesystemloader-class">FileSystemLoader Class</a></li>
<li><a href="#choiceloader-class">ChoiceLoader Class</a></li>
<li><a href="#template-syntax">Template Syntax</a>
<ul>
<li><a href="#variables">Variables</a></li>
@ -279,6 +163,41 @@ var template = env.getTemplate("page.html") // Loads ./templates/page.html</cod
</div>
<p>Checks if a template file exists.</p>
<h2 id="choiceloader-class">ChoiceLoader Class</h2>
<div class="class-header">
<h3>ChoiceLoader</h3>
<p>Chain multiple template loaders</p>
</div>
<p>The ChoiceLoader tries multiple loaders in order until one finds the requested template. This is useful for template inheritance scenarios where templates may be in different directories.</p>
<h3>Constructor</h3>
<div class="method-signature">
<span class="method-name">ChoiceLoader.new</span>(<span class="param">loaders</span>) &rarr; <span class="type">ChoiceLoader</span>
</div>
<p>Creates a loader that chains multiple loaders together.</p>
<ul class="param-list">
<li><span class="param-name">loaders</span> <span class="param-type">(List)</span> - List of loaders to try in order</li>
</ul>
<pre><code>var templatesLoader = FileSystemLoader.new("./templates")
var pagesLoader = FileSystemLoader.new("./pages")
var loader = ChoiceLoader.new([templatesLoader, pagesLoader])
var env = Environment.new(loader)</code></pre>
<h3>Methods</h3>
<div class="method-signature">
<span class="method-name">getSource</span>(<span class="param">name</span>) &rarr; <span class="type">String</span>
</div>
<p>Tries each loader in order and returns the source from the first one that has the template.</p>
<div class="method-signature">
<span class="method-name">exists</span>(<span class="param">name</span>) &rarr; <span class="type">Bool</span>
</div>
<p>Returns true if any loader has the template.</p>
<h2 id="template-syntax">Template Syntax</h2>
<p>The jinja module uses syntax compatible with Jinja2/Twig template engines.</p>
@ -371,10 +290,10 @@ var template = env.getTemplate("page.html") // Loads ./templates/page.html</cod
<h4>Raw Blocks</h4>
<p>Output template syntax literally without processing:</p>
<pre><code>{% raw %}
This {{ will not }} be processed.
{% Neither will this %}
{% endraw %}</code></pre>
<pre><code>&#123;% raw %&#125;
This &#123;&#123; will not &#125;&#125; be processed.
&#123;% Neither will this %&#125;
&#123;% endraw %&#125;</code></pre>
<h4>Filter Blocks</h4>
<p>Apply a filter to an entire block of content:</p>
@ -1106,14 +1025,5 @@ System.print(template.render({
<div class="admonition-title">Warning</div>
<p>When auto-escaping is disabled, be careful with user-provided content to prevent XSS vulnerabilities. Use the <code>|escape</code> filter explicitly when needed.</p>
</div>
</article>
<footer class="page-footer">
<a href="regex.html" class="prev">regex</a>
<a href="crypto.html" class="next">crypto</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endraw %}
{% endblock %}

View File

@ -0,0 +1,166 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "json" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "json"}] %}
{% set prev_page = {"url": "api/dns.html", "title": "dns"} %}
{% set next_page = {"url": "api/base64.html", "title": "base64"} %}
{% block article %}
<h1>json</h1>
<p>The <code>json</code> module provides JSON parsing and stringification. It uses the cJSON library for parsing and implements stringify in Wren.</p>
<pre><code>import "json" for Json</code></pre>
<h2>Json Class</h2>
<div class="class-header">
<h3>Json</h3>
<p>JSON parsing and stringification</p>
</div>
<h3>Static Methods</h3>
<div class="method-signature">
<span class="method-name">Json.parse</span>(<span class="param">string</span>) → <span class="type">Map|List|String|Num|Bool|null</span>
</div>
<p>Parses a JSON string and returns the corresponding Wren value.</p>
<ul class="param-list">
<li><span class="param-name">string</span> <span class="param-type">(String)</span> - JSON string to parse</li>
<li><span class="returns">Returns:</span> Parsed value (Map, List, String, Num, Bool, or null)</li>
</ul>
<pre><code>var data = Json.parse('{"name": "Alice", "age": 30}')
System.print(data["name"]) // Alice
System.print(data["age"]) // 30
var list = Json.parse('[1, 2, 3]')
System.print(list[0]) // 1</code></pre>
<div class="method-signature">
<span class="method-name">Json.stringify</span>(<span class="param">value</span>) → <span class="type">String</span>
</div>
<p>Converts a Wren value to a JSON string (compact, no whitespace).</p>
<ul class="param-list">
<li><span class="param-name">value</span> <span class="param-type">(any)</span> - Value to stringify</li>
<li><span class="returns">Returns:</span> JSON string</li>
</ul>
<pre><code>var json = Json.stringify({"name": "Alice", "age": 30})
System.print(json) // {"name":"Alice","age":30}</code></pre>
<div class="method-signature">
<span class="method-name">Json.stringify</span>(<span class="param">value</span>, <span class="param">indent</span>) → <span class="type">String</span>
</div>
<p>Converts a Wren value to a formatted JSON string with indentation.</p>
<ul class="param-list">
<li><span class="param-name">value</span> <span class="param-type">(any)</span> - Value to stringify</li>
<li><span class="param-name">indent</span> <span class="param-type">(Num|String)</span> - Number of spaces or indent string</li>
<li><span class="returns">Returns:</span> Formatted JSON string</li>
</ul>
<pre><code>var json = Json.stringify({"name": "Alice"}, 2)
System.print(json)
// {
// "name": "Alice"
// }
var json2 = Json.stringify({"name": "Bob"}, "\t")
// Uses tab for indentation</code></pre>
<h2>Type Mapping</h2>
<table>
<tr>
<th>JSON Type</th>
<th>Wren Type</th>
</tr>
<tr>
<td>object</td>
<td>Map</td>
</tr>
<tr>
<td>array</td>
<td>List</td>
</tr>
<tr>
<td>string</td>
<td>String</td>
</tr>
<tr>
<td>number</td>
<td>Num</td>
</tr>
<tr>
<td>true/false</td>
<td>Bool</td>
</tr>
<tr>
<td>null</td>
<td>null</td>
</tr>
</table>
<h2>Examples</h2>
<h3>Parsing JSON</h3>
<pre><code>import "json" for Json
var jsonString = '{"users": [{"name": "Alice"}, {"name": "Bob"}]}'
var data = Json.parse(jsonString)
for (user in data["users"]) {
System.print("User: %(user["name"])")
}</code></pre>
<h3>Building and Stringifying</h3>
<pre><code>import "json" for Json
var data = {
"name": "Product",
"price": 29.99,
"tags": ["electronics", "sale"],
"inStock": true,
"metadata": null
}
System.print(Json.stringify(data, 2))</code></pre>
<h3>Nested Structures</h3>
<pre><code>import "json" for Json
var config = {
"server": {
"host": "localhost",
"port": 8080
},
"database": {
"url": "sqlite://data.db"
}
}
var json = Json.stringify(config)
System.print(json)
var parsed = Json.parse(json)
System.print(parsed["server"]["port"]) // 8080</code></pre>
<h3>Special Values</h3>
<pre><code>import "json" for Json
var special = {
"infinity": 1/0,
"nan": 0/0
}
System.print(Json.stringify(special))
// {"infinity":null,"nan":null}
// Infinity and NaN are converted to null</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>Map keys are converted to strings in JSON output. Non-string keys will have their <code>toString</code> method called.</p>
</div>
<div class="admonition warning">
<div class="admonition-title">Warning</div>
<p>Invalid JSON strings will cause a runtime error. Use <code>Fiber.try()</code> to catch parsing errors.</p>
</div>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>markdown - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html" class="active">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>markdown</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "markdown" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "markdown"}] %}
{% set prev_page = {"url": "api/dataset.html", "title": "dataset"} %}
{% set next_page = {"url": "api/web.html", "title": "web"} %}
{% block article %}
<h1>markdown</h1>
<p>The <code>markdown</code> module provides bidirectional conversion between Markdown and HTML. It supports common Markdown syntax including headings, emphasis, code blocks, lists, links, and images.</p>
@ -449,14 +331,4 @@ System.print(clean) // Safe **content**</code></pre>
<div class="admonition-title">Note</div>
<p>Language identifiers after code fences (e.g., <code>```wren</code>) are currently ignored. The code is rendered without syntax highlighting. Consider using a client-side syntax highlighter like Prism.js or highlight.js for the resulting HTML.</p>
</div>
</article>
<footer class="page-footer">
<a href="dataset.html" class="prev">dataset</a>
<a href="web.html" class="next">web</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>math - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html" class="active">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>math</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "math" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "math"}] %}
{% set prev_page = {"url": "api/scheduler.html", "title": "scheduler"} %}
{% set next_page = {"url": "tutorials/index.html", "title": "Tutorials"} %}
{% block article %}
<h1>math</h1>
<p>The <code>math</code> module provides mathematical functions and constants.</p>
@ -315,14 +197,4 @@ var circleArea = Fn.new { |radius|
}
System.print(circleArea.call(5)) // 78.539...</code></pre>
</article>
<footer class="page-footer">
<a href="scheduler.html" class="prev">scheduler</a>
<a href="../tutorials/index.html" class="next">Tutorials</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>net - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html" class="active">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>net</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "net" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "net"}] %}
{% set prev_page = {"url": "api/tls.html", "title": "tls"} %}
{% set next_page = {"url": "api/dns.html", "title": "dns"} %}
{% block article %}
<h1>net</h1>
<p>The <code>net</code> module provides low-level TCP socket and server functionality for network programming. All operations are asynchronous using libuv.</p>
@ -355,14 +237,4 @@ socket.close()</code></pre>
<div class="admonition-title">Warning</div>
<p>Both host and port arguments are validated. Providing a non-string host or non-number port will abort the fiber with an error message.</p>
</div>
</article>
<footer class="page-footer">
<a href="tls.html" class="prev">tls</a>
<a href="dns.html" class="next">dns</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Num - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html" class="active">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>Num</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Num" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "Num"}] %}
{% set prev_page = {"url": "api/string.html", "title": "String"} %}
{% set next_page = {"url": "api/http.html", "title": "http"} %}
{% block article %}
<h1>Num</h1>
<p>The <code>Num</code> class is the core numeric type in Wren. All numbers are double-precision floating point. The class provides arithmetic, trigonometric, bitwise, rounding, query, conversion, and formatting methods.</p>
@ -516,14 +398,4 @@ Num.fromString("nope") // null</code></pre>
<p>Creates an exclusive range from this number to <code>to</code> (excludes the end).</p>
<pre><code>for (i in 1..5) System.print(i) // 1 2 3 4 5
for (i in 1...5) System.print(i) // 1 2 3 4</code></pre>
</article>
<footer class="page-footer">
<a href="string.html" class="prev">String</a>
<a href="http.html" class="next">http</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>os - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html" class="active">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>os</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "os" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "os"}] %}
{% set prev_page = {"url": "api/crypto.html", "title": "crypto"} %}
{% set next_page = {"url": "api/env.html", "title": "env"} %}
{% block article %}
<h1>os</h1>
<p>The <code>os</code> module provides information about the operating system, platform, and current process.</p>
@ -224,6 +106,20 @@ System.print(Process.allArguments) // [wren_cli, script.wren, arg1, arg2]</code
<p>The version string of the Wren-CLI runtime.</p>
<pre><code>System.print(Process.version) // 0.4.0</code></pre>
<h3>Static Methods</h3>
<div class="method-signature">
<span class="method-name">Process.exit</span>(<span class="param">code</span>)
</div>
<p>Terminates the process with the specified exit code.</p>
<ul class="param-list">
<li><span class="param-name">code</span> <span class="param-type">(Num)</span> - Exit code (0 for success, non-zero for error)</li>
</ul>
<pre><code>if (hasError) {
Process.exit(1)
}
Process.exit(0)</code></pre>
<h2 id="examples">Examples</h2>
<h3>Platform-Specific Behavior</h3>
@ -327,14 +223,4 @@ System.print("Input files: %(inputFiles)")</code></pre>
<div class="admonition-title">Tip</div>
<p>Use <code>Platform.isPosix</code> to write cross-platform code that handles path separators, shell commands, and other platform-specific differences.</p>
</div>
</article>
<footer class="page-footer">
<a href="crypto.html" class="prev">crypto</a>
<a href="env.html" class="next">env</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>pathlib - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html" class="active">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>pathlib</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "pathlib" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "pathlib"}] %}
{% set prev_page = {"url": "api/io.html", "title": "io"} %}
{% set next_page = {"url": "api/scheduler.html", "title": "scheduler"} %}
{% block article %}
<h1>pathlib</h1>
<p>The <code>pathlib</code> module provides object-oriented filesystem path operations. Inspired by Python's <code>pathlib</code>, it offers immutable <code>Path</code> objects that combine path manipulation with filesystem I/O in a single interface.</p>
@ -688,14 +570,4 @@ for (p in shortcuts) {
<div class="admonition-title">Tip</div>
<p>Use the <code>/</code> operator for readable path construction: <code>Path.home / ".config" / "myapp" / "settings.json"</code> reads naturally and handles separator insertion automatically.</p>
</div>
</article>
<footer class="page-footer">
<a href="io.html" class="prev">io</a>
<a href="scheduler.html" class="next">scheduler</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>regex - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html" class="active">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>regex</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "regex" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "regex"}] %}
{% set prev_page = {"url": "api/base64.html", "title": "base64"} %}
{% set next_page = {"url": "api/jinja.html", "title": "jinja"} %}
{% block article %}
<h1>regex</h1>
<p>The <code>regex</code> module provides regular expression matching, replacement, and splitting using PCRE-compatible patterns.</p>
@ -265,7 +147,7 @@ System.print(parts) // [a, b, c, d]</code></pre>
<tr>
<td><code>groups</code></td>
<td>List</td>
<td>List of captured groups</td>
<td>List where index 0 is the entire match, index 1+ are capture groups</td>
</tr>
</table>
@ -281,6 +163,11 @@ System.print(m.group(0)) // item-42
System.print(m.group(1)) // item
System.print(m.group(2)) // 42</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>The <code>groups</code> list uses 0-based indexing where <code>groups[0]</code> is the entire match (same as <code>text</code>), and <code>groups[1]</code>, <code>groups[2]</code>, etc. are the captured groups. This is consistent with <code>group(0)</code>, <code>group(1)</code>, etc.</p>
</div>
<h2 id="pattern-syntax">Pattern Syntax</h2>
<h3>Character Classes</h3>
@ -379,14 +266,4 @@ System.print("Path: %(m.group(3))") // /path/to/page</code></pre>
<div class="admonition-title">Note</div>
<p>Remember to escape backslashes in Wren strings. Use <code>\\d</code> instead of <code>\d</code>.</p>
</div>
</article>
<footer class="page-footer">
<a href="base64.html" class="prev">base64</a>
<a href="jinja.html" class="next">jinja</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>scheduler - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html" class="active">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>scheduler</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "scheduler" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "scheduler"}] %}
{% set prev_page = {"url": "api/pathlib.html", "title": "pathlib"} %}
{% set next_page = {"url": "api/math.html", "title": "math"} %}
{% block article %}
<h1>scheduler</h1>
<p>The <code>scheduler</code> module manages the async event loop and fiber scheduling. It is the foundation for all async operations in Wren-CLI.</p>
@ -370,14 +252,4 @@ var r3 = await f3</code></pre>
<div class="admonition-title">Tip</div>
<p>Async operations in Wren-CLI are cooperative, not preemptive. A fiber runs until it explicitly yields or calls an async operation.</p>
</div>
</article>
<footer class="page-footer">
<a href="pathlib.html" class="prev">pathlib</a>
<a href="math.html" class="next">math</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>signal - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html" class="active">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>signal</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "signal" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "signal"}] %}
{% set prev_page = {"url": "api/scheduler.html", "title": "scheduler"} %}
{% set next_page = {"url": "api/sqlite.html", "title": "sqlite"} %}
{% block article %}
<h1>signal</h1>
<p>The <code>signal</code> module provides Unix signal handling capabilities, allowing scripts to trap, ignore, or reset signal handlers.</p>
@ -375,14 +257,4 @@ while (true) {
<div class="admonition-title">Tip</div>
<p>Always implement graceful shutdown handlers for long-running services. Use SIGTERM for clean shutdowns and reserve SIGINT for interactive termination.</p>
</div>
</article>
<footer class="page-footer">
<a href="scheduler.html" class="prev">scheduler</a>
<a href="sqlite.html" class="next">sqlite</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -0,0 +1,167 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "sqlite" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "sqlite"}] %}
{% set prev_page = {"url": "api/signal.html", "title": "signal"} %}
{% set next_page = {"url": "api/subprocess.html", "title": "subprocess"} %}
{% block article %}
<h1>sqlite</h1>
<p>The <code>sqlite</code> module provides SQLite database functionality for persistent data storage.</p>
<pre><code>import "sqlite" for Sqlite</code></pre>
<h2>Sqlite Class</h2>
<div class="class-header">
<h3>Sqlite</h3>
<p>SQLite database connection</p>
</div>
<h3>Constructors</h3>
<div class="method-signature">
<span class="method-name">Sqlite.open</span>(<span class="param">path</span>) → <span class="type">Sqlite</span>
</div>
<p>Opens or creates an SQLite database file.</p>
<ul class="param-list">
<li><span class="param-name">path</span> <span class="param-type">(String)</span> - Path to the database file</li>
<li><span class="returns">Returns:</span> Database connection</li>
</ul>
<pre><code>var db = Sqlite.open("data.db")</code></pre>
<h3>Methods</h3>
<div class="method-signature">
<span class="method-name">execute</span>(<span class="param">sql</span>) → <span class="type">List</span>
</div>
<p>Executes an SQL statement and returns the results.</p>
<ul class="param-list">
<li><span class="param-name">sql</span> <span class="param-type">(String)</span> - SQL statement</li>
<li><span class="returns">Returns:</span> List of result rows (each row is a Map)</li>
</ul>
<pre><code>var rows = db.execute("SELECT * FROM users")
for (row in rows) {
System.print(row["name"])
}</code></pre>
<div class="method-signature">
<span class="method-name">execute</span>(<span class="param">sql</span>, <span class="param">params</span>) → <span class="type">List</span>
</div>
<p>Executes a parameterized SQL statement (prevents SQL injection).</p>
<ul class="param-list">
<li><span class="param-name">sql</span> <span class="param-type">(String)</span> - SQL with ? placeholders</li>
<li><span class="param-name">params</span> <span class="param-type">(List)</span> - Parameter values</li>
</ul>
<pre><code>var rows = db.execute("SELECT * FROM users WHERE age > ?", [18])</code></pre>
<div class="method-signature">
<span class="method-name">lastInsertId</span><span class="type">Num</span>
</div>
<p>Returns the row ID of the last INSERT operation.</p>
<div class="method-signature">
<span class="method-name">close</span>()
</div>
<p>Closes the database connection.</p>
<h2>Examples</h2>
<h3>Creating Tables</h3>
<pre><code>import "sqlite" for Sqlite
var db = Sqlite.open("app.db")
db.execute("
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT UNIQUE,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
")
db.close()</code></pre>
<h3>Inserting Data</h3>
<pre><code>import "sqlite" for Sqlite
var db = Sqlite.open("app.db")
db.execute("INSERT INTO users (name, email) VALUES (?, ?)", ["Alice", "alice@example.com"])
System.print("Inserted user with ID: %(db.lastInsertId)")
db.execute("INSERT INTO users (name, email) VALUES (?, ?)", ["Bob", "bob@example.com"])
db.close()</code></pre>
<h3>Querying Data</h3>
<pre><code>import "sqlite" for Sqlite
var db = Sqlite.open("app.db")
var users = db.execute("SELECT * FROM users ORDER BY name")
for (user in users) {
System.print("%(user["id"]): %(user["name"]) <%(user["email"])>")
}
var user = db.execute("SELECT * FROM users WHERE id = ?", [1])
if (user.count > 0) {
System.print("Found: %(user[0]["name"])")
}
db.close()</code></pre>
<h3>Updating Data</h3>
<pre><code>import "sqlite" for Sqlite
var db = Sqlite.open("app.db")
db.execute("UPDATE users SET email = ? WHERE id = ?", ["newemail@example.com", 1])
db.close()</code></pre>
<h3>Deleting Data</h3>
<pre><code>import "sqlite" for Sqlite
var db = Sqlite.open("app.db")
db.execute("DELETE FROM users WHERE id = ?", [2])
db.close()</code></pre>
<h3>Transactions</h3>
<pre><code>import "sqlite" for Sqlite
var db = Sqlite.open("app.db")
db.execute("BEGIN TRANSACTION")
var fiber = Fiber.new {
db.execute("INSERT INTO users (name, email) VALUES (?, ?)", ["Charlie", "charlie@example.com"])
db.execute("INSERT INTO users (name, email) VALUES (?, ?)", ["Diana", "diana@example.com"])
}
var error = fiber.try()
if (error) {
db.execute("ROLLBACK")
System.print("Error: %(error)")
} else {
db.execute("COMMIT")
System.print("Transaction committed")
}
db.close()</code></pre>
<div class="admonition tip">
<div class="admonition-title">Tip</div>
<p>Always use parameterized queries with <code>?</code> placeholders to prevent SQL injection attacks. Never concatenate user input directly into SQL strings.</p>
</div>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>Use <code>":memory:"</code> as the path for an in-memory database that does not persist to disk.</p>
</div>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>String - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html" class="active">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>String</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "String" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "String"}] %}
{% set prev_page = {"url": "api/index.html", "title": "Overview"} %}
{% set next_page = {"url": "api/http.html", "title": "http"} %}
{% block article %}
<h1>String</h1>
<p>The <code>String</code> class is a core type available globally without imports. Strings in Wren are immutable sequences of bytes, typically representing UTF-8 encoded text. All methods return new strings rather than modifying the original.</p>
@ -460,14 +342,4 @@ System.print(s.reverse) // dlroW olleH</code></pre>
<div class="admonition-title">Note</div>
<p>String is a core type available globally. No <code>import</code> statement is needed. All string methods operate on ASCII characters. Multi-byte UTF-8 characters are preserved but case conversion applies only to ASCII letters (a-z, A-Z).</p>
</div>
</article>
<footer class="page-footer">
<a href="index.html" class="prev">Overview</a>
<a href="http.html" class="next">http</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -0,0 +1,90 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "subprocess" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "subprocess"}] %}
{% set prev_page = {"url": "api/sqlite.html", "title": "sqlite"} %}
{% set next_page = {"url": "api/sysinfo.html", "title": "sysinfo"} %}
{% block article %}
<h1>subprocess</h1>
<p>The <code>subprocess</code> module allows running external commands and capturing their output.</p>
<pre><code>import "subprocess" for Subprocess</code></pre>
<h2>Subprocess Class</h2>
<div class="class-header">
<h3>Subprocess</h3>
<p>External process execution</p>
</div>
<h3>Static Methods</h3>
<div class="method-signature">
<span class="method-name">Subprocess.run</span>(<span class="param">command</span>) → <span class="type">Map</span>
</div>
<p>Runs a command and waits for it to complete.</p>
<ul class="param-list">
<li><span class="param-name">command</span> <span class="param-type">(List)</span> - Command and arguments as a list</li>
<li><span class="returns">Returns:</span> Map with "stdout", "stderr", and "exitCode"</li>
</ul>
<pre><code>var result = Subprocess.run(["ls", "-la"])
System.print("Exit code: %(result["exitCode"])")
System.print("Output: %(result["stdout"])")</code></pre>
<div class="method-signature">
<span class="method-name">Subprocess.run</span>(<span class="param">command</span>, <span class="param">input</span>) → <span class="type">Map</span>
</div>
<p>Runs a command with input data provided to stdin.</p>
<ul class="param-list">
<li><span class="param-name">command</span> <span class="param-type">(List)</span> - Command and arguments</li>
<li><span class="param-name">input</span> <span class="param-type">(String)</span> - Input to send to stdin</li>
</ul>
<pre><code>var result = Subprocess.run(["cat"], "Hello, World!")
System.print(result["stdout"]) // Hello, World!</code></pre>
<h2>Examples</h2>
<h3>Running Commands</h3>
<pre><code>import "subprocess" for Subprocess
var result = Subprocess.run(["echo", "Hello"])
System.print(result["stdout"]) // Hello
var files = Subprocess.run(["ls", "-la", "/tmp"])
System.print(files["stdout"])</code></pre>
<h3>Checking Exit Codes</h3>
<pre><code>import "subprocess" for Subprocess
var result = Subprocess.run(["grep", "pattern", "file.txt"])
if (result["exitCode"] == 0) {
System.print("Found: %(result["stdout"])")
} else {
System.print("Not found or error")
}</code></pre>
<h3>Processing Data</h3>
<pre><code>import "subprocess" for Subprocess
import "json" for Json
var result = Subprocess.run(["curl", "-s", "https://api.example.com/data"])
if (result["exitCode"] == 0) {
var data = Json.parse(result["stdout"])
System.print(data)
}</code></pre>
<h3>Piping Data</h3>
<pre><code>import "subprocess" for Subprocess
var input = "line1\nline2\nline3"
var result = Subprocess.run(["wc", "-l"], input)
System.print("Lines: %(result["stdout"].trim())")</code></pre>
<div class="admonition warning">
<div class="admonition-title">Warning</div>
<p>Commands are not executed through a shell. Use explicit command and argument lists, not shell command strings.</p>
</div>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>sysinfo - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html" class="active">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>sysinfo</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "sysinfo" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "sysinfo"}] %}
{% set prev_page = {"url": "api/subprocess.html", "title": "subprocess"} %}
{% set next_page = {"url": "api/tempfile.html", "title": "tempfile"} %}
{% block article %}
<h1>sysinfo</h1>
<p>The <code>sysinfo</code> module provides system information including CPU details, memory usage, uptime, and network interfaces. All values are retrieved from libuv.</p>
@ -359,14 +241,4 @@ while (true) {
<div class="admonition-title">Tip</div>
<p>Use <code>SysInfo.hrtime</code> for precise performance measurements. It provides nanosecond resolution and is not affected by system clock adjustments.</p>
</div>
</article>
<footer class="page-footer">
<a href="subprocess.html" class="prev">subprocess</a>
<a href="tempfile.html" class="next">tempfile</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>tempfile - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html" class="active">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>tempfile</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "tempfile" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "tempfile"}] %}
{% set prev_page = {"url": "api/sysinfo.html", "title": "sysinfo"} %}
{% set next_page = {"url": "api/timer.html", "title": "timer"} %}
{% block article %}
<h1>tempfile</h1>
<p>The <code>tempfile</code> module provides utilities for creating temporary files and directories. It mirrors Python's <code>tempfile</code> API with three classes: <code>TempFile</code> for low-level operations, <code>NamedTemporaryFile</code> for temporary files with automatic cleanup, and <code>TemporaryDirectory</code> for temporary directories with recursive cleanup.</p>
@ -385,14 +267,4 @@ System.print("Log file: %(tmp.name)")</code></pre>
<div class="admonition-title">Note</div>
<p>File creation via <code>mkstemp</code> uses exclusive creation flags (<code>O_EXCL</code>) for atomic file creation, preventing race conditions between checking for existence and creating the file. Random suffixes are generated using <code>Crypto.randomBytes</code> for cryptographic quality randomness.</p>
</div>
</article>
<footer class="page-footer">
<a href="sysinfo.html" class="prev">sysinfo</a>
<a href="timer.html" class="next">timer</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>timer - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html" class="active">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>timer</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "timer" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "timer"}] %}
{% set prev_page = {"url": "api/tempfile.html", "title": "tempfile"} %}
{% set next_page = {"url": "api/tls.html", "title": "tls"} %}
{% block article %}
<h1>timer</h1>
<p>The <code>timer</code> module provides timing functionality for delays, intervals, and immediate execution.</p>
@ -342,14 +224,4 @@ var handle = Timer.interval(500) {
<div class="admonition-title">Tip</div>
<p>Use <code>Timer.interval</code> for recurring tasks like heartbeats, polling, or animations. The returned handle allows you to stop the interval from within the callback itself.</p>
</div>
</article>
<footer class="page-footer">
<a href="tempfile.html" class="prev">tempfile</a>
<a href="tls.html" class="next">tls</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -0,0 +1,153 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "tls" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "tls"}] %}
{% set prev_page = {"url": "api/timer.html", "title": "timer"} %}
{% set next_page = {"url": "api/udp.html", "title": "udp"} %}
{% block article %}
<h1>tls</h1>
<p>The <code>tls</code> module provides SSL/TLS socket support for secure network connections. It uses OpenSSL for encryption and is used internally by the <code>http</code> module for HTTPS connections.</p>
<pre><code>import "tls" for TlsSocket</code></pre>
<div class="toc">
<h4>On This Page</h4>
<ul>
<li><a href="#tlssocket-class">TlsSocket Class</a></li>
<li><a href="#examples">Examples</a></li>
</ul>
</div>
<h2 id="tlssocket-class">TlsSocket Class</h2>
<div class="class-header">
<h3>TlsSocket</h3>
<p>SSL/TLS encrypted socket connection</p>
</div>
<h3>Static Methods</h3>
<div class="method-signature">
<span class="method-name">TlsSocket.connect</span>(<span class="param">host</span>, <span class="param">port</span>, <span class="param">hostname</span>) &#8594; <span class="type">TlsSocket</span>
</div>
<p>Establishes a TLS connection to a remote server.</p>
<ul class="param-list">
<li><span class="param-name">host</span> <span class="param-type">(String)</span> - IP address to connect to</li>
<li><span class="param-name">port</span> <span class="param-type">(Num)</span> - Port number (typically 443 for HTTPS)</li>
<li><span class="param-name">hostname</span> <span class="param-type">(String)</span> - Server hostname for SNI (Server Name Indication)</li>
<li><span class="returns">Returns:</span> Connected TlsSocket instance</li>
</ul>
<pre><code>var socket = TlsSocket.connect("93.184.216.34", 443, "example.com")</code></pre>
<h3>Methods</h3>
<div class="method-signature">
<span class="method-name">write</span>(<span class="param">text</span>)
</div>
<p>Writes data to the TLS connection. This is an async operation that blocks until the data is sent.</p>
<ul class="param-list">
<li><span class="param-name">text</span> <span class="param-type">(String)</span> - Data to send</li>
</ul>
<pre><code>socket.write("GET / HTTP/1.1\r\nHost: example.com\r\n\r\n")</code></pre>
<div class="method-signature">
<span class="method-name">read</span>() &#8594; <span class="type">String|null</span>
</div>
<p>Reads data from the TLS connection. Blocks until data is available. Returns null when the connection is closed.</p>
<ul class="param-list">
<li><span class="returns">Returns:</span> Data received as a string, or null if connection closed</li>
</ul>
<pre><code>var data = socket.read()
if (data != null) {
System.print(data)
}</code></pre>
<div class="method-signature">
<span class="method-name">close</span>()
</div>
<p>Closes the TLS connection and releases resources.</p>
<pre><code>socket.close()</code></pre>
<h2 id="examples">Examples</h2>
<h3>Basic HTTPS Request</h3>
<pre><code>import "tls" for TlsSocket
import "dns" for Dns
var host = "example.com"
var ip = Dns.lookup(host)
var socket = TlsSocket.connect(ip, 443, host)
socket.write("GET / HTTP/1.1\r\n")
socket.write("Host: %(host)\r\n")
socket.write("Connection: close\r\n")
socket.write("\r\n")
var response = ""
while (true) {
var chunk = socket.read()
if (chunk == null) break
response = response + chunk
}
socket.close()
System.print(response)</code></pre>
<h3>Reading Until Complete</h3>
<pre><code>import "tls" for TlsSocket
import "dns" for Dns
var host = "api.example.com"
var ip = Dns.lookup(host)
var socket = TlsSocket.connect(ip, 443, host)
socket.write("GET /data HTTP/1.1\r\n")
socket.write("Host: %(host)\r\n")
socket.write("Accept: application/json\r\n")
socket.write("Connection: close\r\n\r\n")
var buffer = ""
while (true) {
var data = socket.read()
if (data == null) break
buffer = buffer + data
}
socket.close()
var bodyStart = buffer.indexOf("\r\n\r\n")
if (bodyStart != -1) {
var body = buffer[bodyStart + 4..-1]
System.print("Response body: %(body)")
}</code></pre>
<h3>Using with DNS Resolution</h3>
<pre><code>import "tls" for TlsSocket
import "dns" for Dns
var hostname = "secure.example.com"
var ip = Dns.lookup(hostname, 4)
System.print("Connecting to %(ip)")
var socket = TlsSocket.connect(ip, 443, hostname)
socket.write("GET /secure-endpoint HTTP/1.1\r\nHost: %(hostname)\r\n\r\n")
var response = socket.read()
System.print(response)
socket.close()</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>The <code>hostname</code> parameter is used for SNI (Server Name Indication), which is required when connecting to servers that host multiple domains on the same IP address. It should match the domain name in the server's certificate.</p>
</div>
<div class="admonition tip">
<div class="admonition-title">Tip</div>
<p>For most use cases, consider using the higher-level <code>http</code> module which handles TLS connections, HTTP protocol details, and response parsing automatically.</p>
</div>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>udp - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html" class="active">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>udp</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "udp" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "udp"}] %}
{% set prev_page = {"url": "api/tls.html", "title": "tls"} %}
{% set next_page = {"url": "api/uuid.html", "title": "uuid"} %}
{% block article %}
<h1>udp</h1>
<p>The <code>udp</code> module provides UDP (User Datagram Protocol) socket functionality for connectionless networking. UDP is useful for applications requiring fast, lightweight communication without the overhead of TCP connection management.</p>
@ -433,14 +315,4 @@ socket.close()</code></pre>
<div class="admonition-title">Warning</div>
<p>Multicast group addresses must be in the range 224.0.0.0 to 239.255.255.255. Using addresses outside this range will cause errors.</p>
</div>
</article>
<footer class="page-footer">
<a href="tls.html" class="prev">tls</a>
<a href="uuid.html" class="next">uuid</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -0,0 +1,127 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "uuid" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "uuid"}] %}
{% set prev_page = {"url": "api/udp.html", "title": "udp"} %}
{% set next_page = {"url": "api/wdantic.html", "title": "wdantic"} %}
{% block article %}
<h1>uuid</h1>
<p>The <code>uuid</code> module provides UUID (Universally Unique Identifier) generation and validation. It supports version 4 UUIDs which are randomly generated.</p>
<pre><code>import "uuid" for Uuid</code></pre>
<h2>Uuid Class</h2>
<div class="class-header">
<h3>Uuid</h3>
<p>UUID generation and validation</p>
</div>
<h3>Static Methods</h3>
<div class="method-signature">
<span class="method-name">Uuid.v4</span>() → <span class="type">String</span>
</div>
<p>Generates a new random version 4 UUID.</p>
<ul class="param-list">
<li><span class="returns">Returns:</span> A 36-character UUID string in the format <code>xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx</code></li>
</ul>
<pre><code>var id = Uuid.v4()
System.print(id) // e.g., "550e8400-e29b-41d4-a716-446655440000"</code></pre>
<div class="method-signature">
<span class="method-name">Uuid.isValid</span>(<span class="param">string</span>) → <span class="type">Bool</span>
</div>
<p>Checks if a string is a valid UUID format (any version).</p>
<ul class="param-list">
<li><span class="param-name">string</span> <span class="param-type">(String)</span> - The string to validate</li>
<li><span class="returns">Returns:</span> <code>true</code> if the string is a valid UUID format, <code>false</code> otherwise</li>
</ul>
<pre><code>System.print(Uuid.isValid("550e8400-e29b-41d4-a716-446655440000")) // true
System.print(Uuid.isValid("not-a-uuid")) // false
System.print(Uuid.isValid("550e8400e29b41d4a716446655440000")) // false (missing hyphens)</code></pre>
<div class="method-signature">
<span class="method-name">Uuid.isV4</span>(<span class="param">string</span>) → <span class="type">Bool</span>
</div>
<p>Checks if a string is a valid version 4 UUID.</p>
<ul class="param-list">
<li><span class="param-name">string</span> <span class="param-type">(String)</span> - The string to validate</li>
<li><span class="returns">Returns:</span> <code>true</code> if the string is a valid v4 UUID, <code>false</code> otherwise</li>
</ul>
<pre><code>var id = Uuid.v4()
System.print(Uuid.isV4(id)) // true
System.print(Uuid.isV4("550e8400-e29b-11d4-a716-446655440000")) // false (version 1)</code></pre>
<h2>UUID Format</h2>
<p>UUIDs are 128-bit identifiers represented as 32 hexadecimal characters separated by hyphens into five groups:</p>
<pre><code>xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
8 4 4 4 12 = 32 hex chars + 4 hyphens = 36 chars</code></pre>
<table>
<tr>
<th>Position</th>
<th>Description</th>
</tr>
<tr>
<td>M</td>
<td>Version number (4 for v4 UUIDs)</td>
</tr>
<tr>
<td>N</td>
<td>Variant (8, 9, a, or b for RFC 4122 UUIDs)</td>
</tr>
</table>
<h2>Examples</h2>
<h3>Generating Unique Identifiers</h3>
<pre><code>import "uuid" for Uuid
var userId = Uuid.v4()
var sessionId = Uuid.v4()
System.print("User ID: %(userId)")
System.print("Session ID: %(sessionId)")</code></pre>
<h3>Validating User Input</h3>
<pre><code>import "uuid" for Uuid
var input = "550e8400-e29b-41d4-a716-446655440000"
if (Uuid.isValid(input)) {
System.print("Valid UUID")
if (Uuid.isV4(input)) {
System.print("This is a v4 UUID")
}
} else {
System.print("Invalid UUID format")
}</code></pre>
<h3>Using with Database Records</h3>
<pre><code>import "uuid" for Uuid
class User {
construct new(name) {
_id = Uuid.v4()
_name = name
}
id { _id }
name { _name }
}
var user = User.new("Alice")
System.print("Created user %(user.name) with ID %(user.id)")</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>Version 4 UUIDs are generated using cryptographically secure random bytes from the <code>crypto</code> module. The probability of generating duplicate UUIDs is astronomically low.</p>
</div>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>wdantic - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html" class="active">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>wdantic</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "wdantic" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "wdantic"}] %}
{% set prev_page = {"url": "api/argparse.html", "title": "argparse"} %}
{% set next_page = {"url": "api/dataset.html", "title": "dataset"} %}
{% block article %}
<h1>wdantic</h1>
<p>The <code>wdantic</code> module provides data validation similar to Python's Pydantic. It includes standalone validators and a schema-based validation system for structured data.</p>
@ -429,14 +311,4 @@ if (Validator.json(jsonStr)) {
<div class="admonition-title">Note</div>
<p>Field types automatically coerce values when possible. For example, <code>IntegerField</code> will convert the string <code>"42"</code> to the number <code>42</code>.</p>
</div>
</article>
<footer class="page-footer">
<a href="argparse.html" class="prev">argparse</a>
<a href="dataset.html" class="next">dataset</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>web - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html" class="active">web</a></li>
<li><a href="websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>web</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "web" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "web"}] %}
{% set prev_page = {"url": "api/wdantic.html", "title": "wdantic"} %}
{% set next_page = {"url": "api/websocket.html", "title": "websocket"} %}
{% block article %}
<h1>web</h1>
<p>The <code>web</code> module provides a web framework for building HTTP servers and a client for making HTTP requests. It includes routing, middleware, sessions, static file serving, and class-based views.</p>
@ -1114,14 +996,4 @@ app.run("0.0.0.0", 8080)</code></pre>
<div class="admonition-title">Note</div>
<p>Sessions are stored in memory by default. Data is lost when the server restarts. For production, consider persisting session data to a database.</p>
</div>
</article>
<footer class="page-footer">
<a href="wdantic.html" class="prev">wdantic</a>
<a href="websocket.html" class="next">websocket</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>websocket - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="string.html">String</a></li>
<li><a href="number.html">Num</a></li>
<li><a href="argparse.html">argparse</a></li>
<li><a href="base64.html">base64</a></li>
<li><a href="crypto.html">crypto</a></li>
<li><a href="dataset.html">dataset</a></li>
<li><a href="datetime.html">datetime</a></li>
<li><a href="dns.html">dns</a></li>
<li><a href="env.html">env</a></li>
<li><a href="fswatch.html">fswatch</a></li>
<li><a href="html.html">html</a></li>
<li><a href="http.html">http</a></li>
<li><a href="io.html">io</a></li>
<li><a href="jinja.html">jinja</a></li>
<li><a href="json.html">json</a></li>
<li><a href="markdown.html">markdown</a></li>
<li><a href="math.html">math</a></li>
<li><a href="net.html">net</a></li>
<li><a href="os.html">os</a></li>
<li><a href="pathlib.html">pathlib</a></li>
<li><a href="regex.html">regex</a></li>
<li><a href="scheduler.html">scheduler</a></li>
<li><a href="signal.html">signal</a></li>
<li><a href="sqlite.html">sqlite</a></li>
<li><a href="subprocess.html">subprocess</a></li>
<li><a href="sysinfo.html">sysinfo</a></li>
<li><a href="tempfile.html">tempfile</a></li>
<li><a href="timer.html">timer</a></li>
<li><a href="tls.html">tls</a></li>
<li><a href="udp.html">udp</a></li>
<li><a href="uuid.html">uuid</a></li>
<li><a href="wdantic.html">wdantic</a></li>
<li><a href="web.html">web</a></li>
<li><a href="websocket.html" class="active">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">API Reference</a>
<span class="separator">/</span>
<span>websocket</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "websocket" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "websocket"}] %}
{% set prev_page = {"url": "api/http.html", "title": "http"} %}
{% set next_page = {"url": "api/yaml.html", "title": "yaml"} %}
{% block article %}
<h1>websocket</h1>
<p>The <code>websocket</code> module provides WebSocket client and server functionality implementing the RFC 6455 protocol. It supports both <code>ws://</code> and <code>wss://</code> (secure) connections.</p>
@ -523,14 +405,4 @@ ws.close()</code></pre>
<div class="admonition-title">Note</div>
<p>Ping frames are automatically responded to with pong frames. You typically do not need to handle ping/pong manually unless implementing custom keepalive logic.</p>
</div>
</article>
<footer class="page-footer">
<a href="http.html" class="prev">http</a>
<a href="tls.html" class="next">tls</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -0,0 +1,218 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "yaml" %}
{% set breadcrumb = [{"url": "api/index.html", "title": "API Reference"}, {"title": "yaml"}] %}
{% set prev_page = {"url": "api/websocket.html", "title": "websocket"} %}
{% set next_page = {"url": "tutorials/index.html", "title": "Tutorial List"} %}
{% block article %}
<h1>yaml</h1>
<p>The <code>yaml</code> module provides YAML parsing and stringification. It implements a line-based parser in pure Wren that supports common YAML features including nested structures, lists, and scalar types.</p>
<pre><code>import "yaml" for Yaml</code></pre>
<h2>Yaml Class</h2>
<div class="class-header">
<h3>Yaml</h3>
<p>YAML parsing and stringification</p>
</div>
<h3>Static Methods</h3>
<div class="method-signature">
<span class="method-name">Yaml.parse</span>(<span class="param">text</span>) &rarr; <span class="type">Map|List|String|Num|Bool|null</span>
</div>
<p>Parses a YAML string and returns the corresponding Wren value.</p>
<ul class="param-list">
<li><span class="param-name">text</span> <span class="param-type">(String)</span> - YAML string to parse</li>
<li><span class="returns">Returns:</span> Parsed value (Map, List, String, Num, Bool, or null)</li>
</ul>
<pre><code>var data = Yaml.parse("name: Alice\nage: 30")
System.print(data["name"]) // Alice
System.print(data["age"]) // 30
var list = Yaml.parse("- one\n- two\n- three")
System.print(list[0]) // one</code></pre>
<div class="method-signature">
<span class="method-name">Yaml.stringify</span>(<span class="param">value</span>) &rarr; <span class="type">String</span>
</div>
<p>Converts a Wren value to a YAML string with default indentation (2 spaces).</p>
<ul class="param-list">
<li><span class="param-name">value</span> <span class="param-type">(any)</span> - Value to stringify</li>
<li><span class="returns">Returns:</span> YAML string</li>
</ul>
<pre><code>var yaml = Yaml.stringify({"name": "Alice", "age": 30})
System.print(yaml)
// name: Alice
// age: 30</code></pre>
<div class="method-signature">
<span class="method-name">Yaml.stringify</span>(<span class="param">value</span>, <span class="param">indent</span>) &rarr; <span class="type">String</span>
</div>
<p>Converts a Wren value to a YAML string with custom indentation.</p>
<ul class="param-list">
<li><span class="param-name">value</span> <span class="param-type">(any)</span> - Value to stringify</li>
<li><span class="param-name">indent</span> <span class="param-type">(Num)</span> - Number of spaces for indentation</li>
<li><span class="returns">Returns:</span> YAML string</li>
</ul>
<pre><code>var yaml = Yaml.stringify({"server": {"host": "localhost"}}, 4)
System.print(yaml)
// server:
// host: localhost</code></pre>
<h2>Supported Features</h2>
<h3>Key-Value Pairs</h3>
<pre><code>var data = Yaml.parse("
name: Alice
age: 30
email: alice@example.com
")
System.print(data["name"]) // Alice</code></pre>
<h3>Nested Maps</h3>
<pre><code>var config = Yaml.parse("
database:
host: localhost
port: 5432
credentials:
user: admin
password: secret
")
System.print(config["database"]["host"]) // localhost
System.print(config["database"]["credentials"]["user"]) // admin</code></pre>
<h3>Lists</h3>
<pre><code>var data = Yaml.parse("
languages:
- Wren
- C
- Python
")
for (lang in data["languages"]) {
System.print(lang)
}</code></pre>
<h3>Lists of Maps</h3>
<pre><code>var nav = Yaml.parse("
pages:
- file: index
title: Home
- file: about
title: About Us
")
for (page in nav["pages"]) {
System.print(page["title"])
}</code></pre>
<h3>Comments</h3>
<pre><code>var data = Yaml.parse("
# This is a comment
name: test
# Another comment
value: 123
")
System.print(data["name"]) // test</code></pre>
<h3>Data Types</h3>
<pre><code>var types = Yaml.parse("
string: hello world
number: 42
float: 3.14
bool_true: true
bool_false: false
null_value: null
tilde_null: ~
quoted: \"with:special chars\"
")
System.print(types["string"]) // hello world (String)
System.print(types["number"]) // 42 (Num)
System.print(types["bool_true"]) // true (Bool)
System.print(types["null_value"]) // null</code></pre>
<h2>Type Mapping</h2>
<table>
<tr>
<th>YAML Type</th>
<th>Wren Type</th>
</tr>
<tr>
<td>mapping</td>
<td>Map</td>
</tr>
<tr>
<td>sequence</td>
<td>List</td>
</tr>
<tr>
<td>string</td>
<td>String</td>
</tr>
<tr>
<td>integer/float</td>
<td>Num</td>
</tr>
<tr>
<td>true/false</td>
<td>Bool</td>
</tr>
<tr>
<td>null/~</td>
<td>null</td>
</tr>
</table>
<h2>Examples</h2>
<h3>Configuration File</h3>
<pre><code>import "yaml" for Yaml
import "io" for File
var config = Yaml.parse(File.read("config.yaml"))
System.print("Server: %(config["server"]["host"]):%(config["server"]["port"])")
System.print("Database: %(config["database"]["url"])")</code></pre>
<h3>Building and Stringifying</h3>
<pre><code>import "yaml" for Yaml
var data = {
"name": "Project",
"version": "1.0.0",
"dependencies": ["wren", "libuv"],
"settings": {
"debug": true,
"timeout": 30
}
}
System.print(Yaml.stringify(data))</code></pre>
<h3>Round-Trip</h3>
<pre><code>import "yaml" for Yaml
var original = "
title: Test
items:
- first
- second
"
var parsed = Yaml.parse(original)
var reserialized = Yaml.stringify(parsed)
var reparsed = Yaml.parse(reserialized)
System.print(parsed["title"] == reparsed["title"]) // true</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>This module implements a subset of YAML 1.2 suitable for configuration files. Advanced features like anchors, aliases, multi-line strings with <code>|</code> or <code>&gt;</code>, and tags are not supported.</p>
</div>
<div class="admonition warning">
<div class="admonition-title">Warning</div>
<p>Strings containing special characters (<code>:</code>, <code>#</code>, quotes) should be quoted in YAML input. The stringify method handles this automatically.</p>
</div>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Async Patterns - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="module-overview.html">Module Architecture</a></li>
<li><a href="pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="c-backed-module.html">C-Backed Modules</a></li>
<li><a href="foreign-classes.html">Foreign Classes</a></li>
<li><a href="async-patterns.html" class="active">Async Patterns</a></li>
<li><a href="testing.html">Writing Tests</a></li>
<li><a href="documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Contributing</a>
<span class="separator">/</span>
<span>Async Patterns</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Async Patterns" %}
{% set breadcrumb = [{"url": "contributing/index.html", "title": "Contributing"}, {"title": "Async Patterns"}] %}
{% set prev_page = {"url": "contributing/foreign-classes.html", "title": "Foreign Classes"} %}
{% set next_page = {"url": "contributing/testing.html", "title": "Writing Tests"} %}
{% block article %}
<h1>Async Patterns</h1>
<p>Wren-CLI uses libuv for non-blocking I/O. Wren fibers suspend during I/O operations and resume when complete. This section explains how to implement async operations in C-backed modules.</p>
@ -535,14 +417,4 @@ fiber2.call()</code></pre>
<h2>Next Steps</h2>
<p>See <a href="testing.html">Writing Tests</a> for testing async operations, including the <code>// skip:</code> annotation for tests that require network access.</p>
</article>
<footer class="page-footer">
<a href="foreign-classes.html" class="prev">Foreign Classes</a>
<a href="testing.html" class="next">Writing Tests</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>C-Backed Modules - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="module-overview.html">Module Architecture</a></li>
<li><a href="pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="c-backed-module.html" class="active">C-Backed Modules</a></li>
<li><a href="foreign-classes.html">Foreign Classes</a></li>
<li><a href="async-patterns.html">Async Patterns</a></li>
<li><a href="testing.html">Writing Tests</a></li>
<li><a href="documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Contributing</a>
<span class="separator">/</span>
<span>C-Backed Modules</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "C-Backed Modules" %}
{% set breadcrumb = [{"url": "contributing/index.html", "title": "Contributing"}, {"title": "C-Backed Modules"}] %}
{% set prev_page = {"url": "contributing/pure-wren-module.html", "title": "Pure-Wren Modules"} %}
{% set next_page = {"url": "contributing/foreign-classes.html", "title": "Foreign Classes"} %}
{% block article %}
<h1>C-Backed Modules</h1>
<p>C-backed modules implement foreign methods in C, providing access to system libraries, native performance, or functionality not available in pure Wren. Examples: json, io, net, crypto, tls, sqlite, base64.</p>
@ -527,14 +409,4 @@ END_MODULE</code></pre>
<li><a href="foreign-classes.html">Foreign Classes</a> - for native resource management</li>
<li><a href="async-patterns.html">Async Patterns</a> - for non-blocking I/O operations</li>
</ul>
</article>
<footer class="page-footer">
<a href="pure-wren-module.html" class="prev">Pure-Wren Modules</a>
<a href="foreign-classes.html" class="next">Foreign Classes</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documentation - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="module-overview.html">Module Architecture</a></li>
<li><a href="pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="c-backed-module.html">C-Backed Modules</a></li>
<li><a href="foreign-classes.html">Foreign Classes</a></li>
<li><a href="async-patterns.html">Async Patterns</a></li>
<li><a href="testing.html">Writing Tests</a></li>
<li><a href="documentation.html" class="active">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Contributing</a>
<span class="separator">/</span>
<span>Documentation</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Documentation" %}
{% set breadcrumb = [{"url": "contributing/index.html", "title": "Contributing"}, {"title": "Documentation"}] %}
{% set prev_page = {"url": "contributing/testing.html", "title": "Writing Tests"} %}
{% set next_page = {"url": "api/index.html", "title": "API Reference"} %}
{% block article %}
<h1>Documentation</h1>
<p>The Wren-CLI manual is hand-written HTML in <code>manual/</code>. There is no generation step. Every page is a standalone HTML file sharing common CSS and JavaScript.</p>
@ -485,14 +367,4 @@ System.print(result)&lt;/code&gt;&lt;/pre&gt;
<li>Updated adjacent page footers</li>
<li>Added to index page if applicable</li>
</ul>
</article>
<footer class="page-footer">
<a href="testing.html" class="prev">Writing Tests</a>
<a href="../api/index.html" class="next">API Reference</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Foreign Classes - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="module-overview.html">Module Architecture</a></li>
<li><a href="pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="c-backed-module.html">C-Backed Modules</a></li>
<li><a href="foreign-classes.html" class="active">Foreign Classes</a></li>
<li><a href="async-patterns.html">Async Patterns</a></li>
<li><a href="testing.html">Writing Tests</a></li>
<li><a href="documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Contributing</a>
<span class="separator">/</span>
<span>Foreign Classes</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Foreign Classes" %}
{% set breadcrumb = [{"url": "contributing/index.html", "title": "Contributing"}, {"title": "Foreign Classes"}] %}
{% set prev_page = {"url": "contributing/c-backed-module.html", "title": "C-Backed Modules"} %}
{% set next_page = {"url": "contributing/async-patterns.html", "title": "Async Patterns"} %}
{% block article %}
<h1>Foreign Classes</h1>
<p>Foreign classes allow Wren objects to hold native C data. This is used when a Wren object needs to manage resources like file handles, network sockets, database connections, or any native data structure.</p>
@ -498,14 +380,4 @@ END_MODULE</code></pre>
<h2>Next Steps</h2>
<p>For I/O-bound foreign classes, see <a href="async-patterns.html">Async Patterns</a> to integrate with the libuv event loop.</p>
</article>
<footer class="page-footer">
<a href="c-backed-module.html" class="prev">C-Backed Modules</a>
<a href="async-patterns.html" class="next">Async Patterns</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -0,0 +1,128 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "Contributing" %}
{% set breadcrumb = [{"title": "Contributing"}] %}
{% set prev_page = {"url": "howto/error-handling.html", "title": "Error Handling"} %}
{% set next_page = {"url": "contributing/module-overview.html", "title": "Module Architecture"} %}
{% block article %}
<h1>Contributing</h1>
<p>This guide explains how to contribute new modules to Wren-CLI, write tests, and add documentation. Whether you are adding a pure-Wren module or implementing C-backed foreign methods, this section provides step-by-step instructions.</p>
<div class="toc">
<h4>In This Section</h4>
<ul>
<li><a href="module-overview.html">Module Architecture</a> - Project structure and artifact matrix</li>
<li><a href="pure-wren-module.html">Pure-Wren Modules</a> - Step-by-step for Wren-only modules</li>
<li><a href="c-backed-module.html">C-Backed Modules</a> - Implementing foreign methods in C</li>
<li><a href="foreign-classes.html">Foreign Classes</a> - Native resource management</li>
<li><a href="async-patterns.html">Async Patterns</a> - Scheduler/Fiber and libuv integration</li>
<li><a href="testing.html">Writing Tests</a> - Test structure and annotations</li>
<li><a href="documentation.html">Documentation</a> - Writing manual pages</li>
</ul>
</div>
<h2>Prerequisites</h2>
<p>Before contributing, ensure you have:</p>
<ul>
<li>A working build environment (see <a href="../getting-started/installation.html">Installation</a>)</li>
<li>Python 3 (for utility scripts)</li>
<li>Basic understanding of <a href="../language/index.html">Wren syntax</a></li>
<li>For C-backed modules: familiarity with C and the Wren embedding API</li>
</ul>
<h2>Module Types</h2>
<p>Wren-CLI supports two types of modules:</p>
<table>
<tr>
<th>Type</th>
<th>Description</th>
<th>Files Required</th>
</tr>
<tr>
<td>Pure-Wren</td>
<td>Modules written entirely in Wren. Examples: argparse, html, jinja, http, markdown, dataset, web, websocket, wdantic, uuid, tempfile</td>
<td><code>.wren</code>, <code>.wren.inc</code>, modules.c entry</td>
</tr>
<tr>
<td>C-Backed</td>
<td>Modules with foreign methods implemented in C. Examples: json, io, net, crypto, tls, sqlite, base64</td>
<td><code>.wren</code>, <code>.wren.inc</code>, <code>.c</code>, <code>.h</code>, modules.c entry, Makefile entry</td>
</tr>
</table>
<h2>Workflow Checklist</h2>
<h3>Pure-Wren Module</h3>
<ol>
<li>Create <code>src/module/&lt;name&gt;.wren</code></li>
<li>Generate <code>.wren.inc</code> with <code>python3 util/wren_to_c_string.py</code></li>
<li>Add <code>#include</code> and <code>MODULE</code> block in <code>src/cli/modules.c</code></li>
<li>Build with <code>make clean && make build</code></li>
<li>Create tests in <code>test/&lt;name&gt;/</code></li>
<li>Create example in <code>example/&lt;name&gt;_demo.wren</code></li>
<li>Create <code>manual/api/&lt;name&gt;.html</code></li>
<li>Run <code>make sync-manual</code></li>
<li>Verify with <code>python3 util/test.py &lt;name&gt;</code></li>
</ol>
<h3>C-Backed Module</h3>
<ol>
<li>All pure-Wren steps, plus:</li>
<li>Create <code>src/module/&lt;name&gt;.c</code> with foreign method implementations</li>
<li>Create <code>src/module/&lt;name&gt;.h</code> with function declarations</li>
<li>Add extern declarations in <code>modules.c</code></li>
<li>Add <code>CLASS</code>/<code>METHOD</code> registrations with correct signatures</li>
<li>Add <code>OBJECTS</code> and compilation rule to <code>projects/make/wren_cli.make</code></li>
</ol>
<h2>Build Commands</h2>
<pre><code>make build # Release build
make debug # Debug build
make clean # Clean artifacts
make tests # Build and run all tests
make sync-manual # Sync sidebar across manual pages</code></pre>
<h2>Directory Structure</h2>
<pre><code>src/
cli/
modules.c # Foreign function registry
vm.c # VM and module loading
module/
&lt;name&gt;.wren # Wren interface source
&lt;name&gt;.wren.inc # Generated C string literal
&lt;name&gt;.c # C implementation (if foreign methods)
&lt;name&gt;.h # C header (if foreign methods)
test/
&lt;name&gt;/
&lt;feature&gt;.wren # Test files with annotations
example/
&lt;name&gt;_demo.wren # Usage demonstrations
manual/
api/&lt;name&gt;.html # API documentation</code></pre>
<h2>Getting Help</h2>
<p>If you encounter issues while contributing:</p>
<ul>
<li>Review existing modules as reference implementations</li>
<li>Check the test files for expected behavior patterns</li>
<li>Consult the <a href="module-overview.html">Module Architecture</a> section for detailed artifact requirements</li>
</ul>
<h2>Next Steps</h2>
<p>Start with the <a href="module-overview.html">Module Architecture</a> section to understand the project structure, then proceed to the appropriate module guide based on your needs.</p>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Module Architecture - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="module-overview.html" class="active">Module Architecture</a></li>
<li><a href="pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="c-backed-module.html">C-Backed Modules</a></li>
<li><a href="foreign-classes.html">Foreign Classes</a></li>
<li><a href="async-patterns.html">Async Patterns</a></li>
<li><a href="testing.html">Writing Tests</a></li>
<li><a href="documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Contributing</a>
<span class="separator">/</span>
<span>Module Architecture</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Module Architecture" %}
{% set breadcrumb = [{"url": "contributing/index.html", "title": "Contributing"}, {"title": "Module Architecture"}] %}
{% set prev_page = {"url": "contributing/index.html", "title": "Overview"} %}
{% set next_page = {"url": "contributing/pure-wren-module.html", "title": "Pure-Wren Modules"} %}
{% block article %}
<h1>Module Architecture</h1>
<p>This section explains how Wren-CLI modules are structured, what files each module type requires, and how the build system processes them.</p>
@ -336,14 +218,4 @@ END_MODULE</code></pre>
<li><a href="pure-wren-module.html">Pure-Wren Modules</a> - for modules without C code</li>
<li><a href="c-backed-module.html">C-Backed Modules</a> - for modules with foreign methods</li>
</ul>
</article>
<footer class="page-footer">
<a href="index.html" class="prev">Overview</a>
<a href="pure-wren-module.html" class="next">Pure-Wren Modules</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pure-Wren Modules - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="module-overview.html">Module Architecture</a></li>
<li><a href="pure-wren-module.html" class="active">Pure-Wren Modules</a></li>
<li><a href="c-backed-module.html">C-Backed Modules</a></li>
<li><a href="foreign-classes.html">Foreign Classes</a></li>
<li><a href="async-patterns.html">Async Patterns</a></li>
<li><a href="testing.html">Writing Tests</a></li>
<li><a href="documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Contributing</a>
<span class="separator">/</span>
<span>Pure-Wren Modules</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Pure-Wren Modules" %}
{% set breadcrumb = [{"url": "contributing/index.html", "title": "Contributing"}, {"title": "Pure-Wren Modules"}] %}
{% set prev_page = {"url": "contributing/module-overview.html", "title": "Module Architecture"} %}
{% set next_page = {"url": "contributing/c-backed-module.html", "title": "C-Backed Modules"} %}
{% block article %}
<h1>Pure-Wren Modules</h1>
<p>Pure-Wren modules are written entirely in Wren, with no C code required. They may depend on other modules (both pure-Wren and C-backed) but do not implement any foreign methods themselves.</p>
@ -362,14 +244,4 @@ class Api {
<h2>Next Steps</h2>
<p>If your module requires native functionality not available through existing modules, see <a href="c-backed-module.html">C-Backed Modules</a>.</p>
</article>
<footer class="page-footer">
<a href="module-overview.html" class="prev">Module Architecture</a>
<a href="c-backed-module.html" class="next">C-Backed Modules</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Writing Tests - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="index.html">Overview</a></li>
<li><a href="module-overview.html">Module Architecture</a></li>
<li><a href="pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="c-backed-module.html">C-Backed Modules</a></li>
<li><a href="foreign-classes.html">Foreign Classes</a></li>
<li><a href="async-patterns.html">Async Patterns</a></li>
<li><a href="testing.html" class="active">Writing Tests</a></li>
<li><a href="documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Contributing</a>
<span class="separator">/</span>
<span>Writing Tests</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Writing Tests" %}
{% set breadcrumb = [{"url": "contributing/index.html", "title": "Contributing"}, {"title": "Writing Tests"}] %}
{% set prev_page = {"url": "contributing/async-patterns.html", "title": "Async Patterns"} %}
{% set next_page = {"url": "contributing/documentation.html", "title": "Documentation"} %}
{% block article %}
<h1>Writing Tests</h1>
<p>Wren-CLI uses inline annotations in test files to specify expected behavior. The test runner <code>util/test.py</code> parses these annotations and verifies the output.</p>
@ -429,14 +311,4 @@ MyClass.process(null) // expect runtime error: Input cannot be null.</code></pre
<h2>Next Steps</h2>
<p>After writing tests, add documentation in <a href="documentation.html">Documentation</a>.</p>
</article>
<footer class="page-footer">
<a href="async-patterns.html" class="prev">Async Patterns</a>
<a href="documentation.html" class="next">Documentation</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -0,0 +1,203 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "First Script" %}
{% set breadcrumb = [{"url": "getting-started/index.html", "title": "Getting Started"}, {"title": "First Script"}] %}
{% set prev_page = {"url": "getting-started/installation.html", "title": "Installation"} %}
{% set next_page = {"url": "getting-started/repl.html", "title": "Using the REPL"} %}
{% block article %}
<h1>First Script</h1>
<p>This guide walks you through creating and running your first Wren script. You will learn the basics of printing output, using variables, and importing modules.</p>
<h2>Hello World</h2>
<p>Create a file named <code>hello.wren</code> with the following content:</p>
<pre><code>System.print("Hello, World!")</code></pre>
<p>Run it:</p>
<pre><code>bin/wren_cli hello.wren</code></pre>
<div class="example-output">Hello, World!</div>
<p>The <code>System.print</code> method outputs text to the console followed by a newline.</p>
<h2>Variables and Types</h2>
<p>Wren is dynamically typed. Use <code>var</code> to declare variables:</p>
<pre><code>var name = "Wren"
var version = 0.4
var features = ["fast", "small", "class-based"]
var active = true
System.print("Language: %(name)")
System.print("Version: %(version)")
System.print("Features: %(features)")
System.print("Active: %(active)")</code></pre>
<div class="example-output">Language: Wren
Version: 0.4
Features: [fast, small, class-based]
Active: true</div>
<p>The <code>%(expression)</code> syntax is string interpolation. It evaluates the expression and inserts the result into the string.</p>
<h2>Working with Lists and Maps</h2>
<pre><code>var numbers = [1, 2, 3, 4, 5]
System.print("Count: %(numbers.count)")
System.print("First: %(numbers[0])")
System.print("Last: %(numbers[-1])")
var person = {
"name": "Alice",
"age": 30,
"city": "Amsterdam"
}
System.print("Name: %(person["name"])")</code></pre>
<div class="example-output">Count: 5
First: 1
Last: 5
Name: Alice</div>
<h2>Control Flow</h2>
<pre><code>var score = 85
if (score >= 90) {
System.print("Grade: A")
} else if (score >= 80) {
System.print("Grade: B")
} else {
System.print("Grade: C")
}
for (i in 1..5) {
System.print("Count: %(i)")
}</code></pre>
<div class="example-output">Grade: B
Count: 1
Count: 2
Count: 3
Count: 4
Count: 5</div>
<h2>Functions</h2>
<p>Functions in Wren are created using block syntax:</p>
<pre><code>var greet = Fn.new { |name|
return "Hello, %(name)!"
}
System.print(greet.call("World"))
var add = Fn.new { |a, b| a + b }
System.print(add.call(3, 4))</code></pre>
<div class="example-output">Hello, World!
7</div>
<h2>Classes</h2>
<pre><code>class Person {
construct new(name, age) {
_name = name
_age = age
}
name { _name }
age { _age }
greet() {
System.print("Hello, I'm %(_name)")
}
}
var alice = Person.new("Alice", 30)
alice.greet()
System.print("Age: %(alice.age)")</code></pre>
<div class="example-output">Hello, I'm Alice
Age: 30</div>
<h2>Using Modules</h2>
<p>Wren-CLI provides many built-in modules. Import them to use their functionality:</p>
<pre><code>import "io" for File
var content = File.read("hello.wren")
System.print("File contents:")
System.print(content)</code></pre>
<h3>Making HTTP Requests</h3>
<pre><code>import "http" for Http
import "json" for Json
var response = Http.get("https://httpbin.org/get")
System.print("Status: %(response.status)")
var data = Json.parse(response.body)
System.print("Origin: %(data["origin"])")</code></pre>
<h3>Working with JSON</h3>
<pre><code>import "json" for Json
var data = {
"name": "Wren",
"version": 0.4,
"features": ["fast", "small"]
}
var jsonString = Json.stringify(data)
System.print(jsonString)
var parsed = Json.parse(jsonString)
System.print("Name: %(parsed["name"])")</code></pre>
<h2>Error Handling</h2>
<p>Use <code>Fiber.try</code> to catch runtime errors:</p>
<pre><code>var fiber = Fiber.new {
var x = 1 / 0
}
var error = fiber.try()
if (error) {
System.print("Error: %(error)")
}</code></pre>
<h2>Script Arguments</h2>
<p>Access command-line arguments via <code>Process.arguments</code>:</p>
<pre><code>import "os" for Process
System.print("Script arguments:")
for (arg in Process.arguments) {
System.print(" %(arg)")
}</code></pre>
<p>Run with arguments:</p>
<pre><code>bin/wren_cli script.wren arg1 arg2 arg3</code></pre>
<h2>Exit Codes</h2>
<p>Wren-CLI uses these exit codes:</p>
<table>
<tr>
<th>Code</th>
<th>Meaning</th>
</tr>
<tr>
<td>0</td>
<td>Success</td>
</tr>
<tr>
<td>65</td>
<td>Compile error (syntax error)</td>
</tr>
<tr>
<td>70</td>
<td>Runtime error</td>
</tr>
</table>
<h2>Next Steps</h2>
<ul>
<li><a href="repl.html">Using the REPL</a> - Interactive experimentation</li>
<li><a href="../language/index.html">Language Reference</a> - Deep dive into Wren syntax</li>
<li><a href="../tutorials/index.html">Tutorials</a> - Build real applications</li>
</ul>
{% endblock %}

View File

@ -0,0 +1,104 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "Getting Started" %}
{% set breadcrumb = [{"title": "Getting Started"}] %}
{% set prev_page = {"url": "index.html", "title": "Home"} %}
{% set next_page = {"url": "getting-started/installation.html", "title": "Installation"} %}
{% block article %}
<h1>Getting Started</h1>
<p>Welcome to Wren-CLI, a command-line interface for the Wren programming language extended with powerful modules for networking, file I/O, databases, and more.</p>
<div class="toc">
<h4>In This Section</h4>
<ul>
<li><a href="installation.html">Installation</a> - Build from source on Linux, macOS, or FreeBSD</li>
<li><a href="first-script.html">First Script</a> - Write and run your first Wren program</li>
<li><a href="repl.html">Using the REPL</a> - Interactive experimentation</li>
</ul>
</div>
<h2>What is Wren?</h2>
<p>Wren is a small, fast, class-based scripting language. It has a familiar syntax, first-class functions, and a fiber-based concurrency model. Wren-CLI extends the core language with modules for:</p>
<ul>
<li>HTTP and WebSocket networking</li>
<li>File and directory operations</li>
<li>SQLite database access</li>
<li>JSON and regex processing</li>
<li>Template rendering (Jinja2-compatible)</li>
<li>Cryptographic operations</li>
<li>Process and signal handling</li>
</ul>
<h2>Quick Start</h2>
<p>If you want to dive right in, here is the fastest path to running your first script:</p>
<h3>1. Build</h3>
<pre><code>git clone https://github.com/wren-lang/wren-cli.git
cd wren-cli
cd projects/make && make</code></pre>
<h3>2. Create a Script</h3>
<p>Create a file named <code>hello.wren</code>:</p>
<pre><code>System.print("Hello, Wren!")</code></pre>
<h3>3. Run</h3>
<pre><code>bin/wren_cli hello.wren</code></pre>
<div class="example-output">Hello, Wren!</div>
<h2>Key Concepts</h2>
<p>Before diving deeper, understand these fundamental Wren concepts:</p>
<h3>Everything is an Object</h3>
<p>In Wren, everything is an object, including numbers, strings, and functions. Every object is an instance of a class.</p>
<pre><code>var name = "Wren"
System.print(name.count) // 4
System.print(name.bytes[0]) // 87 (ASCII for 'W')</code></pre>
<h3>Fibers for Concurrency</h3>
<p>Wren uses fibers (cooperative threads) for concurrency. The scheduler module manages async operations.</p>
<pre><code>import "timer" for Timer
Timer.sleep(1000) // Pauses for 1 second
System.print("Done waiting")</code></pre>
<h3>Module System</h3>
<p>Functionality is organized into modules that you import as needed:</p>
<pre><code>import "http" for Http
import "json" for Json
var response = Http.get("https://api.example.com/data")
var data = Json.parse(response.body)</code></pre>
<h2>System Requirements</h2>
<table>
<tr>
<th>Platform</th>
<th>Requirements</th>
</tr>
<tr>
<td>Linux</td>
<td>GCC, Make, OpenSSL development libraries</td>
</tr>
<tr>
<td>macOS</td>
<td>Xcode Command Line Tools, OpenSSL (via Homebrew)</td>
</tr>
<tr>
<td>FreeBSD</td>
<td>GCC or Clang, gmake, OpenSSL</td>
</tr>
</table>
<h2>Next Steps</h2>
<p>Continue with the following sections to learn more:</p>
<ul>
<li><a href="installation.html">Installation</a> - Detailed build instructions for all platforms</li>
<li><a href="first-script.html">First Script</a> - A more detailed walkthrough of your first program</li>
<li><a href="../language/index.html">Language Reference</a> - Learn the Wren language syntax</li>
<li><a href="../api/index.html">API Reference</a> - Explore all available modules</li>
</ul>
{% endblock %}

View File

@ -0,0 +1,160 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "Installation" %}
{% set breadcrumb = [{"url": "getting-started/index.html", "title": "Getting Started"}, {"title": "Installation"}] %}
{% set prev_page = {"url": "getting-started/index.html", "title": "Overview"} %}
{% set next_page = {"url": "getting-started/first-script.html", "title": "First Script"} %}
{% block article %}
<h1>Installation</h1>
<p>Wren-CLI must be built from source. This page covers the build process for Linux, macOS, and FreeBSD.</p>
<div class="toc">
<h4>On This Page</h4>
<ul>
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#linux">Building on Linux</a></li>
<li><a href="#macos">Building on macOS</a></li>
<li><a href="#freebsd">Building on FreeBSD</a></li>
<li><a href="#configurations">Build Configurations</a></li>
<li><a href="#verification">Verifying Installation</a></li>
</ul>
</div>
<h2 id="prerequisites">Prerequisites</h2>
<p>All platforms require:</p>
<ul>
<li>Git</li>
<li>C compiler (GCC or Clang)</li>
<li>Make</li>
<li>OpenSSL development libraries (for TLS/HTTPS support)</li>
<li>Python 3 (for running tests)</li>
</ul>
<h2 id="linux">Building on Linux</h2>
<h3>Install Dependencies</h3>
<p>On Debian/Ubuntu:</p>
<pre><code>sudo apt-get update
sudo apt-get install build-essential libssl-dev git python3</code></pre>
<p>On Fedora/RHEL:</p>
<pre><code>sudo dnf install gcc make openssl-devel git python3</code></pre>
<p>On Arch Linux:</p>
<pre><code>sudo pacman -S base-devel openssl git python</code></pre>
<h3>Build</h3>
<pre><code>git clone https://github.com/wren-lang/wren-cli.git
cd wren-cli
make build</code></pre>
<p>The binary will be created at <code>bin/wren_cli</code>.</p>
<h3>Install System-Wide (Optional)</h3>
<pre><code>sudo cp bin/wren_cli /usr/local/bin/wren</code></pre>
<h2 id="macos">Building on macOS</h2>
<h3>Install Dependencies</h3>
<p>Install Xcode Command Line Tools:</p>
<pre><code>xcode-select --install</code></pre>
<p>Install OpenSSL via Homebrew:</p>
<pre><code>brew install openssl</code></pre>
<h3>Build</h3>
<pre><code>git clone https://github.com/wren-lang/wren-cli.git
cd wren-cli
cd projects/make.mac && make</code></pre>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>If OpenSSL is not found, you may need to set the library path:</p>
<pre><code>export LDFLAGS="-L/opt/homebrew/opt/openssl/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl/include"</code></pre>
</div>
<h2 id="freebsd">Building on FreeBSD</h2>
<h3>Install Dependencies</h3>
<pre><code>sudo pkg install gmake git python3</code></pre>
<h3>Build</h3>
<pre><code>git clone https://github.com/wren-lang/wren-cli.git
cd wren-cli
cd projects/make.bsd && gmake</code></pre>
<h2 id="configurations">Build Configurations</h2>
<p>Several build configurations are available:</p>
<table>
<tr>
<th>Configuration</th>
<th>Description</th>
</tr>
<tr>
<td><code>release_64bit</code></td>
<td>Default optimized 64-bit build</td>
</tr>
<tr>
<td><code>release_32bit</code></td>
<td>Optimized 32-bit build</td>
</tr>
<tr>
<td><code>debug_64bit</code></td>
<td>Debug build with symbols</td>
</tr>
<tr>
<td><code>debug_32bit</code></td>
<td>32-bit debug build</td>
</tr>
<tr>
<td><code>release_64bit-no-nan-tagging</code></td>
<td>Without NaN tagging optimization</td>
</tr>
<tr>
<td><code>debug_64bit-no-nan-tagging</code></td>
<td>Debug without NaN tagging</td>
</tr>
</table>
<p>To use a specific configuration:</p>
<pre><code>make config=debug_64bit</code></pre>
<p>Debug builds output to <code>bin/wren_cli_d</code>.</p>
<h2 id="verification">Verifying Installation</h2>
<p>Verify the build was successful:</p>
<pre><code>bin/wren_cli --version</code></pre>
<p>Run the test suite:</p>
<pre><code>make tests</code></pre>
<p>Start the REPL:</p>
<pre><code>bin/wren_cli</code></pre>
<div class="example-output">> </div>
<p>Type <code>System.print("Hello")</code> and press Enter to verify the REPL works.</p>
<h2>Troubleshooting</h2>
<h3>OpenSSL Not Found</h3>
<p>If you see errors about missing OpenSSL headers:</p>
<ul>
<li>Verify OpenSSL development packages are installed</li>
<li>On macOS, ensure Homebrew OpenSSL path is in your environment</li>
</ul>
<h3>Build Errors</h3>
<p>Try cleaning and rebuilding:</p>
<pre><code>make clean
make build</code></pre>
<h3>Test Failures</h3>
<p>Run a specific test module to isolate issues:</p>
<pre><code>python3 util/test.py json</code></pre>
{% endblock %}

View File

@ -0,0 +1,151 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "Using the REPL" %}
{% set breadcrumb = [{"url": "getting-started/index.html", "title": "Getting Started"}, {"title": "Using the REPL"}] %}
{% set prev_page = {"url": "getting-started/first-script.html", "title": "First Script"} %}
{% set next_page = {"url": "language/index.html", "title": "Language Reference"} %}
{% block article %}
<h1>Using the REPL</h1>
<p>The REPL (Read-Eval-Print Loop) is an interactive environment for experimenting with Wren code. It is useful for testing ideas, exploring APIs, and learning the language.</p>
<h2>Starting the REPL</h2>
<p>Run <code>wren_cli</code> without arguments to start the REPL:</p>
<pre><code>bin/wren_cli</code></pre>
<p>You will see a prompt:</p>
<div class="example-output">> </div>
<h2>Basic Usage</h2>
<p>Type expressions and press Enter to evaluate them:</p>
<pre><code>> 1 + 2
3
> "hello".count
5
> [1, 2, 3].map { |x| x * 2 }
[2, 4, 6]</code></pre>
<h2>Multi-line Input</h2>
<p>The REPL automatically detects incomplete expressions and waits for more input:</p>
<pre><code>> class Person {
| construct new(name) {
| _name = name
| }
| name { _name }
| }
null
> var p = Person.new("Alice")
null
> p.name
Alice</code></pre>
<p>The <code>|</code> prompt indicates the REPL is waiting for more input.</p>
<h2>Importing Modules</h2>
<p>Modules can be imported in the REPL just like in scripts:</p>
<pre><code>> import "json" for Json
null
> Json.stringify({"name": "Wren"})
{"name":"Wren"}
> import "math" for Math
null
> Math.sqrt(16)
4</code></pre>
<h2>Variables Persist</h2>
<p>Variables defined in the REPL persist across lines:</p>
<pre><code>> var x = 10
null
> var y = 20
null
> x + y
30</code></pre>
<h2>Examining Values</h2>
<p>Use <code>System.print</code> for formatted output:</p>
<pre><code>> var data = {"name": "Wren", "version": 0.4}
null
> System.print(data)
{name: Wren, version: 0.4}</code></pre>
<p>Check the type of a value:</p>
<pre><code>> 42.type
Num
> "hello".type
String
> [1, 2, 3].type
List</code></pre>
<h2>Exploring Classes</h2>
<p>Examine what methods a class provides:</p>
<pre><code>> String
String
> "test".bytes
[116, 101, 115, 116]
> "test".codePoints.toList
[116, 101, 115, 116]</code></pre>
<h2>Error Handling</h2>
<p>Errors are displayed but do not crash the REPL:</p>
<pre><code>> 1 / 0
infinity
> "test"[10]
Subscript out of bounds.
> undefined_variable
[repl line 1] Error at 'undefined_variable': Variable is used but not defined.</code></pre>
<p>You can continue using the REPL after errors.</p>
<h2>REPL Tips</h2>
<h3>Quick Testing</h3>
<p>Use the REPL to quickly test regular expressions:</p>
<pre><code>> import "regex" for Regex
null
> Regex.new("\\d+").test("abc123")
true
> Regex.new("\\d+").match("abc123def").text
123</code></pre>
<h3>Exploring APIs</h3>
<p>Test module functionality before using it in scripts:</p>
<pre><code>> import "base64" for Base64
null
> Base64.encode("Hello, World!")
SGVsbG8sIFdvcmxkIQ==
> Base64.decode("SGVsbG8sIFdvcmxkIQ==")
Hello, World!</code></pre>
<h3>Date and Time</h3>
<pre><code>> import "datetime" for DateTime
null
> DateTime.now
2024-01-15T10:30:45
> DateTime.now.year
2024</code></pre>
<h2>Exiting the REPL</h2>
<p>Exit the REPL by pressing <code>Ctrl+D</code> (Unix) or <code>Ctrl+Z</code> followed by Enter (Windows).</p>
<h2>Limitations</h2>
<ul>
<li>No command history navigation (arrow keys)</li>
<li>No tab completion</li>
<li>No line editing beyond basic backspace</li>
<li>Cannot redefine classes once defined</li>
</ul>
<div class="admonition tip">
<div class="admonition-title">Tip</div>
<p>For complex experimentation, write code in a file and run it with <code>wren_cli script.wren</code>. The REPL is best for quick tests and exploration.</p>
</div>
<h2>Next Steps</h2>
<ul>
<li><a href="../language/index.html">Language Reference</a> - Learn Wren syntax in detail</li>
<li><a href="../api/index.html">API Reference</a> - Explore available modules</li>
<li><a href="../tutorials/index.html">Tutorials</a> - Build real applications</li>
</ul>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Async Programming - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="index.html">How-To List</a></li>
<li><a href="http-requests.html">HTTP Requests</a></li>
<li><a href="json-parsing.html">JSON Parsing</a></li>
<li><a href="regex-patterns.html">Regex Patterns</a></li>
<li><a href="file-operations.html">File Operations</a></li>
<li><a href="async-operations.html" class="active">Async Operations</a></li>
<li><a href="error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">How-To Guides</a>
<span class="separator">/</span>
<span>Async Operations</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Async Programming" %}
{% set breadcrumb = [{"url": "howto/index.html", "title": "How-To Guides"}, {"title": "Async Operations"}] %}
{% set prev_page = {"url": "howto/file-operations.html", "title": "File Operations"} %}
{% set next_page = {"url": "howto/error-handling.html", "title": "Error Handling"} %}
{% block article %}
<h1>Async Programming</h1>
<p>Wren-CLI provides <code>async</code> and <code>await</code> keywords for writing concurrent code. This guide covers the essential patterns for async programming.</p>
@ -427,14 +309,4 @@ System.print("Cleanup complete, exiting.")</code></pre>
<div class="admonition-title">See Also</div>
<p>For more details, see the <a href="../api/scheduler.html">Scheduler API reference</a> and the <a href="../api/web.html">Web module</a> for HTTP client examples.</p>
</div>
</article>
<footer class="page-footer">
<a href="file-operations.html" class="prev">File Operations</a>
<a href="error-handling.html" class="next">Error Handling</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Error Handling - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="index.html">How-To List</a></li>
<li><a href="http-requests.html">HTTP Requests</a></li>
<li><a href="json-parsing.html">JSON Parsing</a></li>
<li><a href="regex-patterns.html">Regex Patterns</a></li>
<li><a href="file-operations.html">File Operations</a></li>
<li><a href="async-operations.html">Async Operations</a></li>
<li><a href="error-handling.html" class="active">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">How-To Guides</a>
<span class="separator">/</span>
<span>Error Handling</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Error Handling" %}
{% set breadcrumb = [{"url": "howto/index.html", "title": "How-To Guides"}, {"title": "Error Handling"}] %}
{% set prev_page = {"url": "howto/async-operations.html", "title": "Async Operations"} %}
{% set next_page = {"url": "contributing/index.html", "title": "Contributing"} %}
{% block article %}
<h1>Error Handling</h1>
<p>Wren uses fibers for error handling. The <code>fiber.try()</code> method catches errors without crashing your program.</p>
@ -493,14 +375,4 @@ var result = retry.call(Fn.new {
<div class="admonition-title">See Also</div>
<p>For more on fibers, see the <a href="../language/fibers.html">Fibers language guide</a>.</p>
</div>
</article>
<footer class="page-footer">
<a href="async-operations.html" class="prev">Async Operations</a>
<a href="../index.html" class="next">Home</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>File Operations - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="index.html">How-To List</a></li>
<li><a href="http-requests.html">HTTP Requests</a></li>
<li><a href="json-parsing.html">JSON Parsing</a></li>
<li><a href="regex-patterns.html">Regex Patterns</a></li>
<li><a href="file-operations.html" class="active">File Operations</a></li>
<li><a href="async-operations.html">Async Operations</a></li>
<li><a href="error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">How-To Guides</a>
<span class="separator">/</span>
<span>File Operations</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "File Operations" %}
{% set breadcrumb = [{"url": "howto/index.html", "title": "How-To Guides"}, {"title": "File Operations"}] %}
{% set prev_page = {"url": "howto/regex-patterns.html", "title": "Regex Patterns"} %}
{% set next_page = {"url": "howto/async-operations.html", "title": "Async Operations"} %}
{% block article %}
<h1>File Operations</h1>
<h2>Read Entire File</h2>
@ -421,14 +303,4 @@ System.print("Total size: %(size) bytes")</code></pre>
<div class="admonition-title">See Also</div>
<p>For full API documentation, see the <a href="../api/io.html">IO module reference</a>. For object-oriented path manipulation with glob, walk, and tree operations, see the <a href="../api/pathlib.html">pathlib module reference</a>.</p>
</div>
</article>
<footer class="page-footer">
<a href="regex-patterns.html" class="prev">Regex Patterns</a>
<a href="async-operations.html" class="next">Async Operations</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -0,0 +1,234 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "Making HTTP Requests" %}
{% set breadcrumb = [{"url": "howto/index.html", "title": "How-To Guides"}, {"title": "HTTP Requests"}] %}
{% set prev_page = {"url": "howto/index.html", "title": "How-To List"} %}
{% set next_page = {"url": "howto/json-parsing.html", "title": "JSON Parsing"} %}
{% block article %}
<h1>Making HTTP Requests</h1>
<h2>Basic GET Request</h2>
<pre><code>import "http" for Http
var response = Http.get("https://api.example.com/data")
System.print(response.body)</code></pre>
<h2>GET Request with JSON Response</h2>
<pre><code>import "http" for Http
var response = Http.get("https://jsonplaceholder.typicode.com/posts/1")
var data = response.json
System.print("Title: %(data["title"])")</code></pre>
<h2>GET Request with Headers</h2>
<pre><code>import "http" for Http
var response = Http.get("https://api.example.com/data", {
"Accept": "application/json",
"User-Agent": "Wren-CLI/1.0"
})
System.print(response.body)</code></pre>
<h2>POST Request with JSON Body</h2>
<pre><code>import "http" for Http
import "json" for Json
var data = {
"name": "John Doe",
"email": "john@example.com"
}
var response = Http.post(
"https://api.example.com/users",
Json.stringify(data),
{"Content-Type": "application/json"}
)
System.print("Status: %(response.statusCode)")
System.print("Created: %(response.json)")</code></pre>
<h2>PUT Request</h2>
<pre><code>import "http" for Http
import "json" for Json
var data = {
"id": 1,
"name": "Jane Doe",
"email": "jane@example.com"
}
var response = Http.put(
"https://api.example.com/users/1",
Json.stringify(data),
{"Content-Type": "application/json"}
)
System.print("Updated: %(response.statusCode == 200)")</code></pre>
<h2>DELETE Request</h2>
<pre><code>import "http" for Http
var response = Http.delete("https://api.example.com/users/1")
System.print("Deleted: %(response.statusCode == 204)")</code></pre>
<h2>PATCH Request</h2>
<pre><code>import "http" for Http
import "json" for Json
var response = Http.patch(
"https://api.example.com/users/1",
Json.stringify({"email": "newemail@example.com"}),
{"Content-Type": "application/json"}
)
System.print("Patched: %(response.statusCode)")</code></pre>
<h2>Bearer Token Authentication</h2>
<pre><code>import "http" for Http
var token = "your-api-token"
var response = Http.get("https://api.example.com/protected", {
"Authorization": "Bearer %(token)"
})
System.print(response.json)</code></pre>
<h2>Basic Authentication</h2>
<pre><code>import "http" for Http
import "base64" for Base64
var username = "user"
var password = "pass"
var credentials = Base64.encode("%(username):%(password)")
var response = Http.get("https://api.example.com/protected", {
"Authorization": "Basic %(credentials)"
})
System.print(response.body)</code></pre>
<h2>API Key Authentication</h2>
<pre><code>import "http" for Http
var response = Http.get("https://api.example.com/data", {
"X-API-Key": "your-api-key"
})
System.print(response.body)</code></pre>
<h2>Check Response Status</h2>
<pre><code>import "http" for Http
var response = Http.get("https://api.example.com/data")
if (response.statusCode == 200) {
System.print("Success: %(response.json)")
} else if (response.statusCode == 404) {
System.print("Not found")
} else if (response.statusCode >= 500) {
System.print("Server error: %(response.statusCode)")
} else {
System.print("Error: %(response.statusCode)")
}</code></pre>
<h2>Access Response Headers</h2>
<pre><code>import "http" for Http
var response = Http.get("https://api.example.com/data")
System.print("Content-Type: %(response.headers["content-type"])")
System.print("All headers: %(response.headers)")</code></pre>
<h2>URL Query Parameters</h2>
<pre><code>import "http" for Http
var response = Http.get("https://api.example.com/search?q=wren&limit=10")
System.print(response.json)</code></pre>
<h2>Form URL Encoded POST</h2>
<pre><code>import "http" for Http
var body = "username=john&password=secret"
var response = Http.post(
"https://api.example.com/login",
body,
{"Content-Type": "application/x-www-form-urlencoded"}
)
System.print(response.json)</code></pre>
<h2>Download File</h2>
<pre><code>import "http" for Http
import "io" for File
var response = Http.get("https://example.com/file.txt")
if (response.statusCode == 200) {
File.write("downloaded.txt", response.body)
System.print("File downloaded!")
}</code></pre>
<h2>HTTPS Request</h2>
<pre><code>import "http" for Http
var response = Http.get("https://secure.example.com/api")
System.print(response.body)</code></pre>
<h2>Error Handling</h2>
<pre><code>import "http" for Http
var fiber = Fiber.new {
return Http.get("https://api.example.com/data")
}
var response = fiber.try()
if (fiber.error) {
System.print("Request failed: %(fiber.error)")
} else if (response.statusCode >= 400) {
System.print("HTTP error: %(response.statusCode)")
} else {
System.print("Success: %(response.json)")
}</code></pre>
<h2>Retry on Failure</h2>
<pre><code>import "http" for Http
import "timer" for Timer
var fetchWithRetry = Fn.new { |url, maxRetries|
var attempt = 0
while (attempt < maxRetries) {
var fiber = Fiber.new { Http.get(url) }
var response = fiber.try()
if (!fiber.error && response.statusCode == 200) {
return response
}
attempt = attempt + 1
if (attempt < maxRetries) {
Timer.sleep(1000 * attempt)
}
}
return null
}
var response = fetchWithRetry.call("https://api.example.com/data", 3)
if (response) {
System.print(response.json)
} else {
System.print("Failed after 3 retries")
}</code></pre>
<div class="admonition tip">
<div class="admonition-title">See Also</div>
<p>For a complete API client example, see the <a href="../tutorials/http-client.html">HTTP Client Tutorial</a>. For full API documentation, see the <a href="../api/http.html">HTTP module reference</a>.</p>
</div>
{% endblock %}

View File

@ -0,0 +1,110 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "How-To Guides" %}
{% set breadcrumb = [{"title": "How-To Guides"}] %}
{% set prev_page = {"url": "tutorials/web-server.html", "title": "Web Server"} %}
{% set next_page = {"url": "howto/http-requests.html", "title": "HTTP Requests"} %}
{% block article %}
<h1>How-To Guides</h1>
<p>Quick, focused guides that show you how to accomplish specific tasks. Each guide provides working code examples you can copy and adapt for your projects.</p>
<div class="card-grid">
<div class="card">
<h3><a href="http-requests.html">Making HTTP Requests</a></h3>
<p>GET, POST, PUT, DELETE requests with headers, authentication, and error handling.</p>
<div class="card-meta">
<span class="tag">http</span>
</div>
</div>
<div class="card">
<h3><a href="json-parsing.html">Working with JSON</a></h3>
<p>Parse JSON strings, access nested data, create JSON output, and handle errors.</p>
<div class="card-meta">
<span class="tag">json</span>
</div>
</div>
<div class="card">
<h3><a href="regex-patterns.html">Using Regular Expressions</a></h3>
<p>Match, search, replace, and split text with regex patterns.</p>
<div class="card-meta">
<span class="tag">regex</span>
</div>
</div>
<div class="card">
<h3><a href="file-operations.html">File Operations</a></h3>
<p>Read, write, copy, and delete files. Work with directories and paths.</p>
<div class="card-meta">
<span class="tag">io</span>
</div>
</div>
<div class="card">
<h3><a href="async-operations.html">Async Programming</a></h3>
<p>Use fibers for concurrent operations, parallel requests, and timeouts.</p>
<div class="card-meta">
<span class="tag">fibers</span>
<span class="tag">scheduler</span>
</div>
</div>
<div class="card">
<h3><a href="error-handling.html">Error Handling</a></h3>
<p>Catch errors with fibers, validate input, and handle edge cases gracefully.</p>
<div class="card-meta">
<span class="tag">fibers</span>
</div>
</div>
</div>
<h2>How-To vs Tutorials</h2>
<p><strong>Tutorials</strong> are learning-oriented. They walk you through building complete applications step by step, introducing concepts gradually.</p>
<p><strong>How-To Guides</strong> are goal-oriented. They assume you know the basics and need to accomplish a specific task quickly. Each guide focuses on one topic with copy-paste examples.</p>
<h2>Quick Reference</h2>
<table>
<tr>
<th>Task</th>
<th>Guide</th>
<th>Key Functions</th>
</tr>
<tr>
<td>Fetch data from API</td>
<td><a href="http-requests.html">HTTP Requests</a></td>
<td><code>Http.get()</code>, <code>response.json</code></td>
</tr>
<tr>
<td>Parse JSON string</td>
<td><a href="json-parsing.html">JSON Parsing</a></td>
<td><code>Json.parse()</code></td>
</tr>
<tr>
<td>Validate email format</td>
<td><a href="regex-patterns.html">Regex Patterns</a></td>
<td><code>Regex.new().test()</code></td>
</tr>
<tr>
<td>Read file contents</td>
<td><a href="file-operations.html">File Operations</a></td>
<td><code>File.read()</code></td>
</tr>
<tr>
<td>Run tasks in parallel</td>
<td><a href="async-operations.html">Async Operations</a></td>
<td><code>Fiber.new { }</code></td>
</tr>
<tr>
<td>Handle runtime errors</td>
<td><a href="error-handling.html">Error Handling</a></td>
<td><code>fiber.try()</code></td>
</tr>
</table>
{% endblock %}

View File

@ -0,0 +1,243 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "Working with JSON" %}
{% set breadcrumb = [{"url": "howto/index.html", "title": "How-To Guides"}, {"title": "JSON Parsing"}] %}
{% set prev_page = {"url": "howto/http-requests.html", "title": "HTTP Requests"} %}
{% set next_page = {"url": "howto/regex-patterns.html", "title": "Regex Patterns"} %}
{% block article %}
<h1>Working with JSON</h1>
<h2>Parse JSON String</h2>
<pre><code>import "json" for Json
var jsonStr = '{"name": "Alice", "age": 30}'
var data = Json.parse(jsonStr)
System.print(data["name"]) // Alice
System.print(data["age"]) // 30</code></pre>
<h2>Parse JSON Array</h2>
<pre><code>import "json" for Json
var jsonStr = '[1, 2, 3, "four", true, null]'
var items = Json.parse(jsonStr)
for (item in items) {
System.print(item)
}</code></pre>
<h2>Access Nested Objects</h2>
<pre><code>import "json" for Json
var jsonStr = '{"user": {"name": "Bob", "address": {"city": "NYC"}}}'
var data = Json.parse(jsonStr)
System.print(data["user"]["name"]) // Bob
System.print(data["user"]["address"]["city"]) // NYC</code></pre>
<h2>Convert Wren Object to JSON</h2>
<pre><code>import "json" for Json
var data = {
"name": "Charlie",
"age": 25,
"active": true
}
var jsonStr = Json.stringify(data)
System.print(jsonStr) // {"name":"Charlie","age":25,"active":true}</code></pre>
<h2>Pretty Print JSON</h2>
<pre><code>import "json" for Json
var data = {
"users": [
{"name": "Alice", "age": 30},
{"name": "Bob", "age": 25}
]
}
var pretty = Json.stringify(data, 2)
System.print(pretty)</code></pre>
<p>Output:</p>
<pre><code>{
"users": [
{
"name": "Alice",
"age": 30
},
{
"name": "Bob",
"age": 25
}
]
}</code></pre>
<h2>Check if Key Exists</h2>
<pre><code>import "json" for Json
var data = Json.parse('{"name": "Alice"}')
if (data.containsKey("name")) {
System.print("Name: %(data["name"])")
}
if (!data.containsKey("age")) {
System.print("Age not specified")
}</code></pre>
<h2>Provide Default Values</h2>
<pre><code>import "json" for Json
var data = Json.parse('{"name": "Alice"}')
var name = data["name"]
var age = data.containsKey("age") ? data["age"] : 0
var city = data.containsKey("city") ? data["city"] : "Unknown"
System.print("%(name), %(age), %(city)")</code></pre>
<h2>Iterate Over Object Keys</h2>
<pre><code>import "json" for Json
var data = Json.parse('{"a": 1, "b": 2, "c": 3}')
for (key in data.keys) {
System.print("%(key): %(data[key])")
}</code></pre>
<h2>Iterate Over Array</h2>
<pre><code>import "json" for Json
var users = Json.parse('[{"name": "Alice"}, {"name": "Bob"}]')
for (i in 0...users.count) {
System.print("%(i + 1). %(users[i]["name"])")
}</code></pre>
<h2>Modify JSON Data</h2>
<pre><code>import "json" for Json
var data = Json.parse('{"name": "Alice", "age": 30}')
data["age"] = 31
data["email"] = "alice@example.com"
data.remove("name")
System.print(Json.stringify(data))</code></pre>
<h2>Parse JSON from File</h2>
<pre><code>import "json" for Json
import "io" for File
var content = File.read("config.json")
var config = Json.parse(content)
System.print(config["setting"])</code></pre>
<h2>Write JSON to File</h2>
<pre><code>import "json" for Json
import "io" for File
var data = {
"database": "myapp.db",
"port": 8080,
"debug": true
}
File.write("config.json", Json.stringify(data, 2))</code></pre>
<h2>Handle Parse Errors</h2>
<pre><code>import "json" for Json
var jsonStr = "invalid json {"
var fiber = Fiber.new { Json.parse(jsonStr) }
var result = fiber.try()
if (fiber.error) {
System.print("Parse error: %(fiber.error)")
} else {
System.print(result)
}</code></pre>
<h2>Work with Null Values</h2>
<pre><code>import "json" for Json
var data = Json.parse('{"name": "Alice", "address": null}')
if (data["address"] == null) {
System.print("No address provided")
}
var output = {"value": null}
System.print(Json.stringify(output)) // {"value":null}</code></pre>
<h2>Build JSON Array Dynamically</h2>
<pre><code>import "json" for Json
var users = []
users.add({"name": "Alice", "role": "admin"})
users.add({"name": "Bob", "role": "user"})
users.add({"name": "Charlie", "role": "user"})
System.print(Json.stringify(users, 2))</code></pre>
<h2>Filter JSON Array</h2>
<pre><code>import "json" for Json
var users = Json.parse('[
{"name": "Alice", "age": 30},
{"name": "Bob", "age": 17},
{"name": "Charlie", "age": 25}
]')
var adults = []
for (user in users) {
if (user["age"] >= 18) {
adults.add(user)
}
}
System.print("Adults: %(Json.stringify(adults))")</code></pre>
<h2>Transform JSON Data</h2>
<pre><code>import "json" for Json
var users = Json.parse('[
{"firstName": "Alice", "lastName": "Smith"},
{"firstName": "Bob", "lastName": "Jones"}
]')
var names = []
for (user in users) {
names.add("%(user["firstName"]) %(user["lastName"])")
}
System.print(names.join(", "))</code></pre>
<h2>Merge JSON Objects</h2>
<pre><code>import "json" for Json
var defaults = {"theme": "light", "language": "en", "timeout": 30}
var userPrefs = {"theme": "dark"}
var config = {}
for (key in defaults.keys) {
config[key] = defaults[key]
}
for (key in userPrefs.keys) {
config[key] = userPrefs[key]
}
System.print(Json.stringify(config, 2))</code></pre>
<div class="admonition tip">
<div class="admonition-title">See Also</div>
<p>For full API documentation, see the <a href="../api/json.html">JSON module reference</a>.</p>
</div>
{% endblock %}

View File

@ -0,0 +1,237 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "Using Regular Expressions" %}
{% set breadcrumb = [{"url": "howto/index.html", "title": "How-To Guides"}, {"title": "Regex Patterns"}] %}
{% set prev_page = {"url": "howto/json-parsing.html", "title": "JSON Parsing"} %}
{% set next_page = {"url": "howto/file-operations.html", "title": "File Operations"} %}
{% block article %}
<h1>Using Regular Expressions</h1>
<h2>Test if String Matches Pattern</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("^hello")
System.print(pattern.test("hello world")) // true
System.print(pattern.test("say hello")) // false</code></pre>
<h2>Find First Match</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("\\d+")
var match = pattern.match("Order 12345 shipped")
if (match) {
System.print(match.text) // 12345
System.print(match.start) // 6
System.print(match.end) // 11
}</code></pre>
<h2>Find All Matches</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("\\d+")
var matches = pattern.matchAll("Items: 10, 20, 30")
for (match in matches) {
System.print(match.text)
}
// 10
// 20
// 30</code></pre>
<h2>Capture Groups</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("(\\w+)@(\\w+\\.\\w+)")
var match = pattern.match("Contact: alice@example.com")
if (match) {
System.print(match.group(0)) // alice@example.com
System.print(match.group(1)) // alice
System.print(match.group(2)) // example.com
}</code></pre>
<h2>Replace Matches</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("\\bcat\\b")
var result = pattern.replace("The cat sat on the cat mat", "dog")
System.print(result) // The dog sat on the dog mat</code></pre>
<h2>Replace with Callback</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("\\d+")
var result = pattern.replace("a1b2c3", Fn.new { |match|
return "[%(match.text)]"
})
System.print(result) // a[1]b[2]c[3]</code></pre>
<h2>Split String</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("[,;\\s]+")
var parts = pattern.split("apple, banana; cherry date")
for (part in parts) {
System.print(part)
}
// apple
// banana
// cherry
// date</code></pre>
<h2>Case Insensitive Matching</h2>
<pre><code>import "regex" for Regex
var pattern = Regex.new("hello", "i")
System.print(pattern.test("Hello World")) // true
System.print(pattern.test("HELLO")) // true</code></pre>
<h2>Multiline Matching</h2>
<pre><code>import "regex" for Regex
var text = "Line 1\nLine 2\nLine 3"
var pattern = Regex.new("^Line", "m")
var matches = pattern.matchAll(text)
System.print(matches.count) // 3</code></pre>
<h2>Common Patterns</h2>
<h3>Validate Email</h3>
<pre><code>import "regex" for Regex
var emailPattern = Regex.new("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$")
System.print(emailPattern.test("user@example.com")) // true
System.print(emailPattern.test("invalid-email")) // false</code></pre>
<h3>Validate URL</h3>
<pre><code>import "regex" for Regex
var urlPattern = Regex.new("^https?://[a-zA-Z0-9.-]+(/.*)?$")
System.print(urlPattern.test("https://example.com")) // true
System.print(urlPattern.test("http://example.com/path")) // true
System.print(urlPattern.test("ftp://invalid")) // false</code></pre>
<h3>Validate Phone Number</h3>
<pre><code>import "regex" for Regex
var phonePattern = Regex.new("^\\+?\\d{1,3}[-.\\s]?\\(?\\d{3}\\)?[-.\\s]?\\d{3}[-.\\s]?\\d{4}$")
System.print(phonePattern.test("+1-555-123-4567")) // true
System.print(phonePattern.test("(555) 123-4567")) // true</code></pre>
<h3>Extract Numbers</h3>
<pre><code>import "regex" for Regex
var numberPattern = Regex.new("-?\\d+\\.?\\d*")
var text = "Temperature: -5.5 to 32.0 degrees"
var matches = numberPattern.matchAll(text)
for (match in matches) {
System.print(match.text)
}
// -5.5
// 32.0</code></pre>
<h3>Extract Hashtags</h3>
<pre><code>import "regex" for Regex
var hashtagPattern = Regex.new("#\\w+")
var text = "Check out #wren and #programming!"
var matches = hashtagPattern.matchAll(text)
for (match in matches) {
System.print(match.text)
}
// #wren
// #programming</code></pre>
<h3>Remove HTML Tags</h3>
<pre><code>import "regex" for Regex
var tagPattern = Regex.new("<[^>]+>")
var html = "<p>Hello <b>World</b>!</p>"
var text = tagPattern.replace(html, "")
System.print(text) // Hello World!</code></pre>
<h3>Validate Password Strength</h3>
<pre><code>import "regex" for Regex
var hasUpper = Regex.new("[A-Z]")
var hasLower = Regex.new("[a-z]")
var hasDigit = Regex.new("\\d")
var hasSpecial = Regex.new("[!@#$%^&*]")
var minLength = 8
var validatePassword = Fn.new { |password|
if (password.count < minLength) return false
if (!hasUpper.test(password)) return false
if (!hasLower.test(password)) return false
if (!hasDigit.test(password)) return false
if (!hasSpecial.test(password)) return false
return true
}
System.print(validatePassword.call("Weak")) // false
System.print(validatePassword.call("Strong@Pass1")) // true</code></pre>
<h3>Parse Log Lines</h3>
<pre><code>import "regex" for Regex
var logPattern = Regex.new("\\[(\\d{4}-\\d{2}-\\d{2})\\]\\s+(\\w+):\\s+(.+)")
var line = "[2024-01-15] ERROR: Connection failed"
var match = logPattern.match(line)
if (match) {
System.print("Date: %(match.group(1))") // 2024-01-15
System.print("Level: %(match.group(2))") // ERROR
System.print("Message: %(match.group(3))") // Connection failed
}</code></pre>
<h3>Validate IP Address</h3>
<pre><code>import "regex" for Regex
var ipPattern = Regex.new("^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$")
System.print(ipPattern.test("192.168.1.1")) // true
System.print(ipPattern.test("256.1.1.1")) // false
System.print(ipPattern.test("10.0.0.255")) // true</code></pre>
<h2>Pattern Syntax Quick Reference</h2>
<table>
<tr><th>Pattern</th><th>Description</th></tr>
<tr><td><code>.</code></td><td>Any character except newline</td></tr>
<tr><td><code>\\d</code></td><td>Digit (0-9)</td></tr>
<tr><td><code>\\w</code></td><td>Word character (a-z, A-Z, 0-9, _)</td></tr>
<tr><td><code>\\s</code></td><td>Whitespace</td></tr>
<tr><td><code>^</code></td><td>Start of string/line</td></tr>
<tr><td><code>$</code></td><td>End of string/line</td></tr>
<tr><td><code>*</code></td><td>Zero or more</td></tr>
<tr><td><code>+</code></td><td>One or more</td></tr>
<tr><td><code>?</code></td><td>Zero or one</td></tr>
<tr><td><code>{n,m}</code></td><td>Between n and m times</td></tr>
<tr><td><code>[abc]</code></td><td>Character class</td></tr>
<tr><td><code>[^abc]</code></td><td>Negated character class</td></tr>
<tr><td><code>(group)</code></td><td>Capture group</td></tr>
<tr><td><code>a|b</code></td><td>Alternation (a or b)</td></tr>
<tr><td><code>\\b</code></td><td>Word boundary</td></tr>
</table>
<div class="admonition tip">
<div class="admonition-title">See Also</div>
<p>For full API documentation, see the <a href="../api/regex.html">Regex module reference</a>.</p>
</div>
{% endblock %}

View File

@ -0,0 +1,93 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'home.html' %}
{% set page_title = "Wren-CLI Manual" %}
{% set next_page = {"url": "getting-started/index.html", "title": "Getting Started"} %}
{% block article %}
<h2>What is Wren-CLI?</h2>
<p>Wren-CLI is a command-line interface for the <a href="https://wren.io">Wren programming language</a>, extended with powerful modules for networking, file I/O, databases, and more. It provides an async event loop powered by libuv, making it suitable for building servers, automation scripts, and command-line tools.</p>
<div class="card-grid">
<div class="card">
<h3><a href="getting-started/index.html">Getting Started</a></h3>
<p>Install Wren-CLI, write your first script, and learn the basics of the language.</p>
</div>
<div class="card">
<h3><a href="language/index.html">Language Reference</a></h3>
<p>Learn about classes, methods, control flow, fibers, and the module system.</p>
</div>
<div class="card">
<h3><a href="api/index.html">API Reference</a></h3>
<p>Complete documentation for all 32 built-in modules including HTTP, WebSocket, and SQLite.</p>
</div>
<div class="card">
<h3><a href="tutorials/index.html">Tutorials</a></h3>
<p>Step-by-step guides for building real applications with Wren-CLI.</p>
</div>
</div>
<h2>Available Modules</h2>
<p>Wren-CLI provides a rich set of modules for common programming tasks:</p>
<h3>Networking</h3>
<div class="module-grid">
<a href="api/http.html" class="module-card">http</a>
<a href="api/websocket.html" class="module-card">websocket</a>
<a href="api/tls.html" class="module-card">tls</a>
<a href="api/net.html" class="module-card">net</a>
<a href="api/udp.html" class="module-card">udp</a>
<a href="api/dns.html" class="module-card">dns</a>
</div>
<h3>Data Processing</h3>
<div class="module-grid">
<a href="api/json.html" class="module-card">json</a>
<a href="api/base64.html" class="module-card">base64</a>
<a href="api/regex.html" class="module-card">regex</a>
<a href="api/jinja.html" class="module-card">jinja</a>
<a href="api/crypto.html" class="module-card">crypto</a>
</div>
<h3>System</h3>
<div class="module-grid">
<a href="api/os.html" class="module-card">os</a>
<a href="api/env.html" class="module-card">env</a>
<a href="api/signal.html" class="module-card">signal</a>
<a href="api/subprocess.html" class="module-card">subprocess</a>
<a href="api/io.html" class="module-card">io</a>
<a href="api/pathlib.html" class="module-card">pathlib</a>
<a href="api/sysinfo.html" class="module-card">sysinfo</a>
<a href="api/fswatch.html" class="module-card">fswatch</a>
</div>
<h3>Data & Time</h3>
<div class="module-grid">
<a href="api/sqlite.html" class="module-card">sqlite</a>
<a href="api/datetime.html" class="module-card">datetime</a>
<a href="api/timer.html" class="module-card">timer</a>
<a href="api/math.html" class="module-card">math</a>
<a href="api/scheduler.html" class="module-card">scheduler</a>
</div>
<h2>Quick Example</h2>
<pre><code>import "http" for Http
import "json" for Json
var response = Http.get("https://api.github.com/users/wren-lang")
var data = Json.parse(response.body)
System.print("User: %(data["login"])")
System.print("Repos: %(data["public_repos"])")</code></pre>
<h2>Features</h2>
<ul>
<li><strong>Async I/O</strong> - Non-blocking operations powered by libuv</li>
<li><strong>HTTP/HTTPS</strong> - Full HTTP client with TLS support</li>
<li><strong>WebSocket</strong> - Client and server WebSocket support</li>
<li><strong>SQLite</strong> - Embedded database for persistent storage</li>
<li><strong>Templates</strong> - Jinja2-compatible template engine</li>
<li><strong>Regex</strong> - Full regular expression support</li>
<li><strong>Cross-platform</strong> - Runs on Linux, macOS, and FreeBSD</li>
</ul>
{% endblock %}

View File

@ -0,0 +1,322 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "Classes" %}
{% set breadcrumb = [{"url": "language/index.html", "title": "Language"}, {"title": "Classes"}] %}
{% set prev_page = {"url": "language/index.html", "title": "Syntax Overview"} %}
{% set next_page = {"url": "language/methods.html", "title": "Methods"} %}
{% block article %}
<h1>Classes</h1>
<p>Wren is a class-based object-oriented language. Everything in Wren is an object, and every object is an instance of a class.</p>
<h2>Defining Classes</h2>
<p>Define a class with the <code>class</code> keyword:</p>
<pre><code>class Animal {
}</code></pre>
<p>This creates a class named <code>Animal</code> with no methods or fields.</p>
<h2>Constructors</h2>
<p>Constructors create new instances. Define them with <code>construct</code>:</p>
<pre><code>class Person {
construct new(name, age) {
_name = name
_age = age
}
}
var alice = Person.new("Alice", 30)</code></pre>
<p>A class can have multiple named constructors:</p>
<pre><code>class Point {
construct new(x, y) {
_x = x
_y = y
}
construct origin() {
_x = 0
_y = 0
}
construct fromList(list) {
_x = list[0]
_y = list[1]
}
}
var p1 = Point.new(3, 4)
var p2 = Point.origin()
var p3 = Point.fromList([5, 6])</code></pre>
<h2>Fields</h2>
<p>Instance fields are prefixed with <code>_</code>. They are private to the class:</p>
<pre><code>class Counter {
construct new() {
_count = 0
}
increment() {
_count = _count + 1
}
count { _count }
}</code></pre>
<p>Fields are not declared; they are created when first assigned.</p>
<h2>Getters and Setters</h2>
<p>Getters are methods without parentheses:</p>
<pre><code>class Circle {
construct new(radius) {
_radius = radius
}
radius { _radius }
area { 3.14159 * _radius * _radius }
}
var c = Circle.new(5)
System.print(c.radius) // 5
System.print(c.area) // 78.53975</code></pre>
<p>Setters use <code>=</code> suffix:</p>
<pre><code>class Circle {
construct new(radius) {
_radius = radius
}
radius { _radius }
radius=(value) { _radius = value }
}
var c = Circle.new(5)
c.radius = 10
System.print(c.radius) // 10</code></pre>
<h2>Methods</h2>
<p>Methods are defined inside the class body:</p>
<pre><code>class Rectangle {
construct new(width, height) {
_width = width
_height = height
}
area() {
return _width * _height
}
perimeter() {
return 2 * (_width + _height)
}
}
var rect = Rectangle.new(4, 5)
System.print(rect.area()) // 20
System.print(rect.perimeter()) // 18</code></pre>
<h2>Static Members</h2>
<p>Static methods and fields belong to the class, not instances:</p>
<pre><code>class Math {
static pi { 3.14159 }
static square(x) {
return x * x
}
static cube(x) {
return x * x * x
}
}
System.print(Math.pi) // 3.14159
System.print(Math.square(4)) // 16
System.print(Math.cube(3)) // 27</code></pre>
<p>Static fields use double underscore:</p>
<pre><code>class Counter {
static count { __count }
static increment() {
if (__count == null) __count = 0
__count = __count + 1
}
}
Counter.increment()
Counter.increment()
System.print(Counter.count) // 2</code></pre>
<h2>Inheritance</h2>
<p>Classes can inherit from a single superclass using <code>is</code>:</p>
<pre><code>class Animal {
construct new(name) {
_name = name
}
name { _name }
speak() {
System.print("...")
}
}
class Dog is Animal {
construct new(name, breed) {
super(name)
_breed = breed
}
breed { _breed }
speak() {
System.print("Woof!")
}
}
var dog = Dog.new("Rex", "German Shepherd")
System.print(dog.name) // Rex
System.print(dog.breed) // German Shepherd
dog.speak() // Woof!</code></pre>
<h3>Calling Super</h3>
<p>Use <code>super</code> to call the superclass constructor or methods:</p>
<pre><code>class Parent {
construct new() {
_value = 10
}
value { _value }
describe() {
System.print("Parent value: %(_value)")
}
}
class Child is Parent {
construct new() {
super()
_extra = 20
}
describe() {
super.describe()
System.print("Child extra: %(_extra)")
}
}
var child = Child.new()
child.describe()
// Output:
// Parent value: 10
// Child extra: 20</code></pre>
<h2>This</h2>
<p>Use <code>this</code> to refer to the current instance:</p>
<pre><code>class Node {
construct new(value) {
_value = value
_next = null
}
value { _value }
next { _next }
append(value) {
_next = Node.new(value)
return this
}
}
var n = Node.new(1).append(2).append(3)</code></pre>
<h2>Object Class</h2>
<p>All classes implicitly inherit from <code>Object</code>:</p>
<pre><code>class Foo {}
System.print(Foo is Class) // true
System.print(Foo.supertype) // Object</code></pre>
<h2>Type Checking</h2>
<p>Use <code>is</code> to check if an object is an instance of a class:</p>
<pre><code>var dog = Dog.new("Rex", "Shepherd")
System.print(dog is Dog) // true
System.print(dog is Animal) // true
System.print(dog is Object) // true
System.print(dog is String) // false</code></pre>
<p>Get the class of an object with <code>type</code>:</p>
<pre><code>System.print(dog.type) // Dog
System.print(dog.type.name) // Dog
System.print(dog.type.supertype) // Animal</code></pre>
<h2>Foreign Classes</h2>
<p>Foreign classes are implemented in C. They can hold native data:</p>
<pre><code>foreign class Socket {
construct new() {}
foreign connect(host, port)
foreign send(data)
foreign receive()
foreign close()
}</code></pre>
<p>Foreign classes are used by built-in modules to provide native functionality.</p>
<h2>Complete Example</h2>
<pre><code>class Shape {
construct new() {}
area { 0 }
perimeter { 0 }
describe() {
System.print("Area: %(area)")
System.print("Perimeter: %(perimeter)")
}
}
class Rectangle is Shape {
construct new(width, height) {
_width = width
_height = height
}
width { _width }
height { _height }
area { _width * _height }
perimeter { 2 * (_width + _height) }
}
class Square is Rectangle {
construct new(side) {
super(side, side)
}
}
class Circle is Shape {
construct new(radius) {
_radius = radius
}
static pi { 3.14159 }
radius { _radius }
area { Circle.pi * _radius * _radius }
perimeter { 2 * Circle.pi * _radius }
}
var shapes = [
Rectangle.new(4, 5),
Square.new(3),
Circle.new(2)
]
for (shape in shapes) {
System.print("%(shape.type.name):")
shape.describe()
System.print("")
}</code></pre>
{% endblock %}

View File

@ -0,0 +1,232 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "Control Flow" %}
{% set breadcrumb = [{"url": "language/index.html", "title": "Language"}, {"title": "Control Flow"}] %}
{% set prev_page = {"url": "language/methods.html", "title": "Methods"} %}
{% set next_page = {"url": "language/fibers.html", "title": "Fibers"} %}
{% block article %}
<h1>Control Flow</h1>
<p>Wren provides standard control flow constructs for conditionals, loops, and early exit.</p>
<h2>Truthiness</h2>
<p>Before covering control flow, understand how Wren evaluates truthiness:</p>
<ul>
<li><code>false</code> is falsy</li>
<li><code>null</code> is falsy</li>
<li>Everything else is truthy (including <code>0</code>, <code>""</code>, <code>[]</code>)</li>
</ul>
<pre><code>if (0) System.print("0 is truthy")
if ("") System.print("empty string is truthy")
if ([]) System.print("empty list is truthy")
if (false) System.print("false is falsy") // Not printed
if (null) System.print("null is falsy") // Not printed</code></pre>
<h2>If Statements</h2>
<p>Basic conditional execution:</p>
<pre><code>if (condition) {
System.print("condition is true")
}</code></pre>
<h3>If-Else</h3>
<pre><code>if (score >= 90) {
System.print("A")
} else {
System.print("Not A")
}</code></pre>
<h3>If-Else If-Else</h3>
<pre><code>if (score >= 90) {
System.print("A")
} else if (score >= 80) {
System.print("B")
} else if (score >= 70) {
System.print("C")
} else {
System.print("F")
}</code></pre>
<h3>Single Expression</h3>
<p>For single expressions, braces are optional:</p>
<pre><code>if (x > 0) System.print("positive")</code></pre>
<h2>Ternary Operator</h2>
<p>For inline conditionals:</p>
<pre><code>var status = age >= 18 ? "adult" : "minor"
var max = a > b ? a : b</code></pre>
<h2>Logical Operators</h2>
<h3>And (&&)</h3>
<p>Returns the first falsy value or the last value:</p>
<pre><code>System.print(true && false) // false
System.print(true && true) // true
System.print(1 && 2) // 2
System.print(null && 1) // null</code></pre>
<h3>Or (||)</h3>
<p>Returns the first truthy value or the last value:</p>
<pre><code>System.print(false || true) // true
System.print(false || false) // false
System.print(null || "default") // default
System.print(1 || 2) // 1</code></pre>
<p>Use <code>||</code> for default values:</p>
<pre><code>var name = providedName || "Anonymous"</code></pre>
<h2>While Loops</h2>
<p>Repeat while a condition is true:</p>
<pre><code>var i = 0
while (i &lt; 5) {
System.print(i)
i = i + 1
}</code></pre>
<div class="example-output">0
1
2
3
4</div>
<h2>For Loops</h2>
<p>Iterate over any sequence:</p>
<pre><code>for (item in [1, 2, 3]) {
System.print(item)
}</code></pre>
<h3>Range Iteration</h3>
<pre><code>for (i in 1..5) {
System.print(i)
}
// Prints: 1 2 3 4 5
for (i in 1...5) {
System.print(i)
}
// Prints: 1 2 3 4 (exclusive)</code></pre>
<h3>String Iteration</h3>
<pre><code>for (char in "hello") {
System.print(char)
}
// Prints each character</code></pre>
<h3>Map Iteration</h3>
<pre><code>var person = {"name": "Alice", "age": 30}
for (key in person.keys) {
System.print("%(key): %(person[key])")
}</code></pre>
<h2>Break</h2>
<p>Exit a loop early:</p>
<pre><code>for (i in 1..100) {
if (i > 5) break
System.print(i)
}
// Prints: 1 2 3 4 5</code></pre>
<h2>Continue</h2>
<p>Skip to the next iteration:</p>
<pre><code>for (i in 1..10) {
if (i % 2 == 0) continue
System.print(i)
}
// Prints: 1 3 5 7 9 (odd numbers only)</code></pre>
<h2>Block Scoping</h2>
<p>Blocks create new scopes:</p>
<pre><code>var x = "outer"
{
var x = "inner"
System.print(x) // inner
}
System.print(x) // outer</code></pre>
<p>Variables declared in a block are not visible outside:</p>
<pre><code>if (true) {
var temp = "temporary"
}
// temp is not accessible here</code></pre>
<h2>Iterating with Index</h2>
<p>Use range to get indices:</p>
<pre><code>var list = ["a", "b", "c"]
for (i in 0...list.count) {
System.print("%(i): %(list[i])")
}</code></pre>
<div class="example-output">0: a
1: b
2: c</div>
<h2>Infinite Loops</h2>
<p>Create with <code>while (true)</code>:</p>
<pre><code>var count = 0
while (true) {
count = count + 1
if (count >= 5) break
System.print(count)
}</code></pre>
<h2>Nested Loops</h2>
<pre><code>for (i in 1..3) {
for (j in 1..3) {
System.print("%(i), %(j)")
}
}</code></pre>
<p>Break only exits the innermost loop:</p>
<pre><code>for (i in 1..3) {
for (j in 1..10) {
if (j > 2) break // Only breaks inner loop
System.print("%(i), %(j)")
}
}</code></pre>
<h2>Iteration Patterns</h2>
<h3>Filtering</h3>
<pre><code>var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
var evens = []
for (n in numbers) {
if (n % 2 == 0) evens.add(n)
}
System.print(evens) // [2, 4, 6, 8, 10]</code></pre>
<h3>Mapping</h3>
<pre><code>var numbers = [1, 2, 3, 4, 5]
var squared = []
for (n in numbers) {
squared.add(n * n)
}
System.print(squared) // [1, 4, 9, 16, 25]</code></pre>
<h3>Finding</h3>
<pre><code>var numbers = [1, 3, 5, 8, 9, 11]
var firstEven = null
for (n in numbers) {
if (n % 2 == 0) {
firstEven = n
break
}
}
System.print(firstEven) // 8</code></pre>
<h3>Reducing</h3>
<pre><code>var numbers = [1, 2, 3, 4, 5]
var sum = 0
for (n in numbers) {
sum = sum + n
}
System.print(sum) // 15</code></pre>
<h2>Functional Alternatives</h2>
<p>Lists provide functional methods that are often cleaner:</p>
<pre><code>var numbers = [1, 2, 3, 4, 5]
var evens = numbers.where { |n| n % 2 == 0 }.toList
var squared = numbers.map { |n| n * n }.toList
var sum = numbers.reduce(0) { |acc, n| acc + n }</code></pre>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fibers - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="index.html">Syntax Overview</a></li>
<li><a href="classes.html">Classes</a></li>
<li><a href="methods.html">Methods</a></li>
<li><a href="control-flow.html">Control Flow</a></li>
<li><a href="fibers.html" class="active">Fibers</a></li>
<li><a href="modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Language</a>
<span class="separator">/</span>
<span>Fibers</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Fibers" %}
{% set breadcrumb = [{"url": "language/index.html", "title": "Language"}, {"title": "Fibers"}] %}
{% set prev_page = {"url": "language/control-flow.html", "title": "Control Flow"} %}
{% set next_page = {"url": "language/modules.html", "title": "Modules"} %}
{% block article %}
<h1>Fibers</h1>
<p>Fibers are Wren's mechanism for cooperative concurrency. They are lightweight threads of execution that you explicitly control. Unlike OS threads, only one fiber runs at a time, and switching between them is explicit.</p>
@ -399,14 +281,4 @@ System.print("done")
// in b
// back in a
// done</code></pre>
</article>
<footer class="page-footer">
<a href="control-flow.html" class="prev">Control Flow</a>
<a href="modules.html" class="next">Modules</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -0,0 +1,204 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "Syntax Overview" %}
{% set breadcrumb = [{"title": "Language Reference"}] %}
{% set prev_page = {"url": "getting-started/repl.html", "title": "Using the REPL"} %}
{% set next_page = {"url": "language/classes.html", "title": "Classes"} %}
{% block article %}
<h1>Syntax Overview</h1>
<p>Wren is a small, fast, class-based scripting language with a clean syntax inspired by languages like Dart, Lua, and Smalltalk. This section covers the core language features.</p>
<div class="toc">
<h4>Language Topics</h4>
<ul>
<li><a href="classes.html">Classes</a> - Object-oriented programming</li>
<li><a href="methods.html">Methods</a> - Method definition and operators</li>
<li><a href="control-flow.html">Control Flow</a> - Conditionals and loops</li>
<li><a href="fibers.html">Fibers</a> - Cooperative concurrency</li>
<li><a href="modules.html">Modules</a> - Import system</li>
</ul>
</div>
<h2>Comments</h2>
<p>Single-line comments start with <code>//</code>:</p>
<pre><code>// This is a comment
var x = 42 // Inline comment</code></pre>
<p>Block comments use <code>/* */</code> and can nest:</p>
<pre><code>/* This is a
multi-line comment */
/* Outer /* nested */ comment */</code></pre>
<h2>Variables</h2>
<p>Declare variables with <code>var</code>:</p>
<pre><code>var name = "Wren"
var count = 42
var active = true
var nothing = null</code></pre>
<p>Variables must be initialized when declared. They are lexically scoped:</p>
<pre><code>var outer = "outside"
{
var inner = "inside"
System.print(outer) // Works
}
// inner is not accessible here</code></pre>
<h2>Data Types</h2>
<h3>Numbers</h3>
<p>All numbers are 64-bit floating point:</p>
<pre><code>var integer = 42
var decimal = 3.14159
var negative = -100
var scientific = 1.5e10
var hex = 0xFF
var binary = 0b1010</code></pre>
<h3>Strings</h3>
<p>Strings are immutable sequences of bytes:</p>
<pre><code>var single = "Hello"
var escape = "Line 1\nLine 2"
var interpolation = "Value: %(1 + 2)"</code></pre>
<p>Raw strings avoid escape processing:</p>
<pre><code>var raw = """
This is a raw string.
Backslashes \ are literal.
"""</code></pre>
<h3>Booleans</h3>
<pre><code>var yes = true
var no = false</code></pre>
<p>Only <code>false</code> and <code>null</code> are falsy. All other values, including <code>0</code> and empty strings, are truthy.</p>
<h3>Null</h3>
<pre><code>var nothing = null</code></pre>
<h3>Ranges</h3>
<p>Ranges represent sequences of numbers:</p>
<pre><code>var inclusive = 1..5 // 1, 2, 3, 4, 5
var exclusive = 1...5 // 1, 2, 3, 4</code></pre>
<h3>Lists</h3>
<p>Ordered, indexable collections:</p>
<pre><code>var empty = []
var numbers = [1, 2, 3, 4, 5]
var mixed = [1, "two", true, null]
System.print(numbers[0]) // 1
System.print(numbers[-1]) // 5 (last element)
numbers[0] = 10
numbers.add(6)</code></pre>
<h3>Maps</h3>
<p>Key-value collections:</p>
<pre><code>var empty = {}
var person = {
"name": "Alice",
"age": 30
}
System.print(person["name"]) // Alice
person["city"] = "Amsterdam"</code></pre>
<h2>Operators</h2>
<h3>Arithmetic</h3>
<pre><code>1 + 2 // 3
5 - 3 // 2
4 * 3 // 12
10 / 4 // 2.5
10 % 3 // 1 (modulo)</code></pre>
<h3>Comparison</h3>
<pre><code>1 == 1 // true
1 != 2 // true
1 &lt; 2 // true
1 &lt;= 1 // true
2 > 1 // true
2 >= 2 // true</code></pre>
<h3>Logical</h3>
<pre><code>true && false // false
true || false // true
!true // false</code></pre>
<p>Logical operators short-circuit:</p>
<pre><code>false && expensive() // expensive() not called
true || expensive() // expensive() not called</code></pre>
<h3>Bitwise</h3>
<pre><code>5 & 3 // 1 (AND)
5 | 3 // 7 (OR)
5 ^ 3 // 6 (XOR)
~5 // -6 (NOT)
8 &lt;&lt; 2 // 32 (left shift)
8 >> 2 // 2 (right shift)</code></pre>
<h3>Ternary</h3>
<pre><code>var result = condition ? valueIfTrue : valueIfFalse</code></pre>
<h2>String Interpolation</h2>
<p>Embed expressions in strings with <code>%()</code>:</p>
<pre><code>var name = "World"
System.print("Hello, %(name)!")
var a = 3
var b = 4
System.print("%(a) + %(b) = %(a + b)")</code></pre>
<p>Any expression can be interpolated:</p>
<pre><code>System.print("Random: %(Random.new().float())")
System.print("List: %([1, 2, 3].map { |x| x * 2 })")</code></pre>
<h2>Blocks</h2>
<p>Blocks are anonymous functions. They use curly braces:</p>
<pre><code>var block = { System.print("Hello") }
block.call()
var add = { |a, b| a + b }
System.print(add.call(1, 2)) // 3</code></pre>
<p>Blocks with a single expression return that value:</p>
<pre><code>var square = { |x| x * x }
System.print(square.call(5)) // 25</code></pre>
<h2>Functions</h2>
<p>Use <code>Fn.new</code> for functions stored in variables:</p>
<pre><code>var greet = Fn.new { |name|
return "Hello, %(name)!"
}
System.print(greet.call("World"))</code></pre>
<p>Functions can have multiple statements:</p>
<pre><code>var factorial = Fn.new { |n|
if (n &lt;= 1) return 1
return n * factorial.call(n - 1)
}</code></pre>
<h2>Is Operator</h2>
<p>Check if an object is an instance of a class:</p>
<pre><code>"hello" is String // true
42 is Num // true
[1, 2] is List // true</code></pre>
<h2>Reserved Words</h2>
<p>The following are reserved and cannot be used as identifiers:</p>
<pre><code>break class construct else false for foreign if import
in is null return static super this true var while</code></pre>
<h2>Identifiers</h2>
<p>Identifiers follow these conventions:</p>
<ul>
<li><code>camelCase</code> for variables and methods</li>
<li><code>PascalCase</code> for class names</li>
<li><code>_underscore</code> prefix for private fields</li>
<li><code>UPPER_CASE</code> for constants (by convention)</li>
</ul>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Methods - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="index.html">Syntax Overview</a></li>
<li><a href="classes.html">Classes</a></li>
<li><a href="methods.html" class="active">Methods</a></li>
<li><a href="control-flow.html">Control Flow</a></li>
<li><a href="fibers.html">Fibers</a></li>
<li><a href="modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Language</a>
<span class="separator">/</span>
<span>Methods</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Methods" %}
{% set breadcrumb = [{"url": "language/index.html", "title": "Language"}, {"title": "Methods"}] %}
{% set prev_page = {"url": "language/classes.html", "title": "Classes"} %}
{% set next_page = {"url": "language/control-flow.html", "title": "Control Flow"} %}
{% block article %}
<h1>Methods</h1>
<p>Methods are the primary way to define behavior in Wren. They can be instance methods, static methods, getters, setters, or operators.</p>
@ -391,14 +273,4 @@ list.each { |x| System.print(x) }</code></pre>
var fn = Fn.new { |x| Printer.print(x) }
fn.call("Hello") // Hello</code></pre>
</article>
<footer class="page-footer">
<a href="classes.html" class="prev">Classes</a>
<a href="control-flow.html" class="next">Control Flow</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Modules - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="index.html">Syntax Overview</a></li>
<li><a href="classes.html">Classes</a></li>
<li><a href="methods.html">Methods</a></li>
<li><a href="control-flow.html">Control Flow</a></li>
<li><a href="fibers.html">Fibers</a></li>
<li><a href="modules.html" class="active">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="../tutorials/index.html">Tutorial List</a></li>
<li><a href="../tutorials/http-client.html">HTTP Client</a></li>
<li><a href="../tutorials/websocket-chat.html">WebSocket Chat</a></li>
<li><a href="../tutorials/database-app.html">Database App</a></li>
<li><a href="../tutorials/template-rendering.html">Templates</a></li>
<li><a href="../tutorials/cli-tool.html">CLI Tool</a></li>
<li><a href="../tutorials/web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Language</a>
<span class="separator">/</span>
<span>Modules</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Modules" %}
{% set breadcrumb = [{"url": "language/index.html", "title": "Language"}, {"title": "Modules"}] %}
{% set prev_page = {"url": "language/fibers.html", "title": "Fibers"} %}
{% set next_page = {"url": "api/index.html", "title": "API Reference"} %}
{% block article %}
<h1>Modules</h1>
<p>Modules organize code into separate, reusable files. Wren-CLI provides built-in modules and supports user-defined modules.</p>
@ -417,14 +299,4 @@ class Lib {
import "./lib/index" for Lib
var client = Lib.httpClient.new()</code></pre>
</article>
<footer class="page-footer">
<a href="fibers.html" class="prev">Fibers</a>
<a href="../api/index.html" class="next">API Reference</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -0,0 +1,85 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "Try Wren" %}
{% set breadcrumb = [{"title": "Playground"}] %}
{% set prev_page = {"url": "getting-started/repl.html", "title": "Using the REPL"} %}
{% set next_page = {"url": "language/index.html", "title": "Syntax Overview"} %}
{% block extra_head %}
<link rel="stylesheet" href="{{ static_prefix }}css/playground.css">
<script src="{{ static_prefix }}wasm/wren.js"></script>
{% endblock %}
{% block article %}
<h1>Try Wren</h1>
<p>Write and run Wren code directly in your browser. This playground uses WebAssembly to run a subset of Wren-CLI modules.</p>
<div class="playground-container">
<div class="playground-toolbar">
<button id="run-button" class="primary" disabled>Run</button>
<button id="clear-button">Clear Output</button>
<select id="example-select">
<option value="">Load Example...</option>
<option value="hello">Hello World</option>
<option value="fibonacci">Fibonacci</option>
<option value="classes">Classes</option>
<option value="math">Math Module</option>
<option value="json">JSON</option>
<option value="datetime">DateTime</option>
<option value="base64">Base64</option>
<option value="strutil">String Utils</option>
<option value="faker">Faker Data</option>
<option value="lists">Lists and Iteration</option>
</select>
<span id="wasm-status" class="wasm-status loading">Loading...</span>
</div>
<div class="playground-editor-wrapper">
<textarea id="wren-editor" spellcheck="false" placeholder="Enter Wren code here...">System.print("Hello, World!")</textarea>
</div>
<div class="output-panel">
<div class="output-header">Output</div>
<pre id="wren-output"></pre>
</div>
<div class="playground-help">
<kbd>Ctrl</kbd> + <kbd>Enter</kbd> to run &bull; <kbd>Tab</kbd> inserts spaces
</div>
</div>
<h2>Available Modules</h2>
<p>The following modules are available in this browser-based playground:</p>
<div class="modules-list">
<span class="module-badge">math</span>
<span class="module-badge">json</span>
<span class="module-badge">base64</span>
<span class="module-badge">bytes</span>
<span class="module-badge">datetime</span>
<span class="module-badge">strutil</span>
<span class="module-badge">html</span>
<span class="module-badge">markdown</span>
<span class="module-badge">argparse</span>
<span class="module-badge">wdantic</span>
<span class="module-badge">uuid</span>
<span class="module-badge">faker</span>
</div>
<div class="admonition note">
<div class="admonition-title">Note</div>
<p>Some modules require system access and are not available in the browser, including: <code>io</code>, <code>net</code>, <code>http</code>, <code>tls</code>, <code>sqlite</code>, <code>subprocess</code>, <code>os</code>, and <code>scheduler</code>.</p>
</div>
<h2>Learn More</h2>
<p>This playground is a quick way to experiment. For full functionality, install Wren-CLI locally:</p>
<ul>
<li><a href="getting-started/installation.html">Installation Guide</a></li>
<li><a href="language/index.html">Language Reference</a></li>
<li><a href="api/index.html">API Reference</a></li>
</ul>
<script src="{{ static_prefix }}js/playground.js"></script>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Building a CLI Tool - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="index.html">Tutorial List</a></li>
<li><a href="http-client.html">HTTP Client</a></li>
<li><a href="websocket-chat.html">WebSocket Chat</a></li>
<li><a href="database-app.html">Database App</a></li>
<li><a href="template-rendering.html">Templates</a></li>
<li><a href="cli-tool.html" class="active">CLI Tool</a></li>
<li><a href="web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Tutorials</a>
<span class="separator">/</span>
<span>CLI Tool</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Building a CLI Tool" %}
{% set breadcrumb = [{"url": "tutorials/index.html", "title": "Tutorials"}, {"title": "CLI Tool"}] %}
{% set prev_page = {"url": "tutorials/template-rendering.html", "title": "Template Rendering"} %}
{% set next_page = {"url": "tutorials/pexpect.html", "title": "Process Automation"} %}
{% block article %}
<h1>Building a CLI Tool</h1>
<p>In this tutorial, you will build a complete command-line application. You will learn to parse arguments, handle user input, run subprocesses, and create a professional CLI experience.</p>
@ -760,14 +642,4 @@ SHA256: a3f2e8b9c4d5...</code></pre>
<li>Add tab completion hints</li>
<li>See the <a href="../api/os.html">OS</a> and <a href="../api/subprocess.html">Subprocess</a> API references</li>
</ul>
</article>
<footer class="page-footer">
<a href="template-rendering.html" class="prev">Template Rendering</a>
<a href="web-server.html" class="next">Web Server</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Database Application - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="index.html">Tutorial List</a></li>
<li><a href="http-client.html">HTTP Client</a></li>
<li><a href="websocket-chat.html">WebSocket Chat</a></li>
<li><a href="database-app.html" class="active">Database App</a></li>
<li><a href="template-rendering.html">Templates</a></li>
<li><a href="cli-tool.html">CLI Tool</a></li>
<li><a href="web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Tutorials</a>
<span class="separator">/</span>
<span>Database App</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Database Application" %}
{% set breadcrumb = [{"url": "tutorials/index.html", "title": "Tutorials"}, {"title": "Database App"}] %}
{% set prev_page = {"url": "tutorials/websocket-chat.html", "title": "WebSocket Chat"} %}
{% set next_page = {"url": "tutorials/template-rendering.html", "title": "Template Rendering"} %}
{% block article %}
<h1>Database Application</h1>
<p>In this tutorial, you will build a complete task management application using SQLite for persistent storage. You will learn to create tables, perform CRUD operations, and build a command-line interface.</p>
@ -743,14 +625,4 @@ Task created with ID: 1</code></pre>
<li>Generate HTML reports with <a href="template-rendering.html">Jinja templates</a></li>
<li>See the <a href="../api/sqlite.html">SQLite API reference</a></li>
</ul>
</article>
<footer class="page-footer">
<a href="websocket-chat.html" class="prev">WebSocket Chat</a>
<a href="template-rendering.html" class="next">Template Rendering</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -1,130 +1,12 @@
<!DOCTYPE html>
<!-- retoor <retoor@molodetz.nl> -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Building an HTTP Client - Wren-CLI Manual</title>
<link rel="stylesheet" href="../css/style.css">
</head>
<body>
<button class="mobile-menu-toggle">Menu</button>
<div class="container">
<aside class="sidebar">
<div class="sidebar-header">
<h1><a href="../index.html">Wren-CLI</a></h1>
<div class="version">v0.4.0</div>
</div>
<nav class="sidebar-nav">
<div class="section">
<span class="section-title">Getting Started</span>
<ul>
<li><a href="../getting-started/index.html">Overview</a></li>
<li><a href="../getting-started/installation.html">Installation</a></li>
<li><a href="../getting-started/first-script.html">First Script</a></li>
<li><a href="../getting-started/repl.html">Using the REPL</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Language</span>
<ul>
<li><a href="../language/index.html">Syntax Overview</a></li>
<li><a href="../language/classes.html">Classes</a></li>
<li><a href="../language/methods.html">Methods</a></li>
<li><a href="../language/control-flow.html">Control Flow</a></li>
<li><a href="../language/fibers.html">Fibers</a></li>
<li><a href="../language/modules.html">Modules</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">API Reference</span>
<ul>
<li><a href="../api/index.html">Overview</a></li>
<li><a href="../api/string.html">String</a></li>
<li><a href="../api/number.html">Num</a></li>
<li><a href="../api/argparse.html">argparse</a></li>
<li><a href="../api/base64.html">base64</a></li>
<li><a href="../api/crypto.html">crypto</a></li>
<li><a href="../api/dataset.html">dataset</a></li>
<li><a href="../api/datetime.html">datetime</a></li>
<li><a href="../api/dns.html">dns</a></li>
<li><a href="../api/env.html">env</a></li>
<li><a href="../api/fswatch.html">fswatch</a></li>
<li><a href="../api/html.html">html</a></li>
<li><a href="../api/http.html">http</a></li>
<li><a href="../api/io.html">io</a></li>
<li><a href="../api/jinja.html">jinja</a></li>
<li><a href="../api/json.html">json</a></li>
<li><a href="../api/markdown.html">markdown</a></li>
<li><a href="../api/math.html">math</a></li>
<li><a href="../api/net.html">net</a></li>
<li><a href="../api/os.html">os</a></li>
<li><a href="../api/pathlib.html">pathlib</a></li>
<li><a href="../api/regex.html">regex</a></li>
<li><a href="../api/scheduler.html">scheduler</a></li>
<li><a href="../api/signal.html">signal</a></li>
<li><a href="../api/sqlite.html">sqlite</a></li>
<li><a href="../api/subprocess.html">subprocess</a></li>
<li><a href="../api/sysinfo.html">sysinfo</a></li>
<li><a href="../api/tempfile.html">tempfile</a></li>
<li><a href="../api/timer.html">timer</a></li>
<li><a href="../api/tls.html">tls</a></li>
<li><a href="../api/udp.html">udp</a></li>
<li><a href="../api/uuid.html">uuid</a></li>
<li><a href="../api/wdantic.html">wdantic</a></li>
<li><a href="../api/web.html">web</a></li>
<li><a href="../api/websocket.html">websocket</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Tutorials</span>
<ul>
<li><a href="index.html">Tutorial List</a></li>
<li><a href="http-client.html" class="active">HTTP Client</a></li>
<li><a href="websocket-chat.html">WebSocket Chat</a></li>
<li><a href="database-app.html">Database App</a></li>
<li><a href="template-rendering.html">Templates</a></li>
<li><a href="cli-tool.html">CLI Tool</a></li>
<li><a href="web-server.html">Web Server</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">How-To Guides</span>
<ul>
<li><a href="../howto/index.html">How-To List</a></li>
<li><a href="../howto/http-requests.html">HTTP Requests</a></li>
<li><a href="../howto/json-parsing.html">JSON Parsing</a></li>
<li><a href="../howto/regex-patterns.html">Regex Patterns</a></li>
<li><a href="../howto/file-operations.html">File Operations</a></li>
<li><a href="../howto/async-operations.html">Async Operations</a></li>
<li><a href="../howto/error-handling.html">Error Handling</a></li>
</ul>
</div>
<div class="section">
<span class="section-title">Contributing</span>
<ul>
<li><a href="../contributing/index.html">Overview</a></li>
<li><a href="../contributing/module-overview.html">Module Architecture</a></li>
<li><a href="../contributing/pure-wren-module.html">Pure-Wren Modules</a></li>
<li><a href="../contributing/c-backed-module.html">C-Backed Modules</a></li>
<li><a href="../contributing/foreign-classes.html">Foreign Classes</a></li>
<li><a href="../contributing/async-patterns.html">Async Patterns</a></li>
<li><a href="../contributing/testing.html">Writing Tests</a></li>
<li><a href="../contributing/documentation.html">Documentation</a></li>
</ul>
</div>
</nav>
</aside>
<main class="content">
<nav class="breadcrumb">
<a href="../index.html">Home</a>
<span class="separator">/</span>
<a href="index.html">Tutorials</a>
<span class="separator">/</span>
<span>HTTP Client</span>
</nav>
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
<article>
{% set page_title = "Building an HTTP Client" %}
{% set breadcrumb = [{"url": "tutorials/index.html", "title": "Tutorials"}, {"title": "HTTP Client"}] %}
{% set prev_page = {"url": "tutorials/index.html", "title": "Tutorials"} %}
{% set next_page = {"url": "tutorials/websocket-chat.html", "title": "WebSocket Chat"} %}
{% block article %}
<h1>Building an HTTP Client</h1>
<p>In this tutorial, you will learn how to build a REST API client using Wren-CLI's <code>http</code> and <code>json</code> modules. By the end, you will have a reusable API client class that can interact with any JSON REST API.</p>
@ -634,14 +516,4 @@ System.print("Delete status: %(result["status"])")</code></pre>
<li>Explore <a href="../api/json.html">JSON module</a> for advanced parsing</li>
<li>Build a <a href="websocket-chat.html">WebSocket chat application</a></li>
</ul>
</article>
<footer class="page-footer">
<a href="index.html" class="prev">Tutorials</a>
<a href="websocket-chat.html" class="next">WebSocket Chat</a>
</footer>
</main>
</div>
<script src="../js/main.js"></script>
</body>
</html>
{% endblock %}

View File

@ -0,0 +1,92 @@
{# retoor <retoor@molodetz.nl> #}
{% extends 'page.html' %}
{% set page_title = "Tutorials" %}
{% set breadcrumb = [{"title": "Tutorials"}] %}
{% set prev_page = {"url": "api/math.html", "title": "math"} %}
{% set next_page = {"url": "tutorials/http-client.html", "title": "HTTP Client"} %}
{% block article %}
<h1>Tutorials</h1>
<p>Step-by-step tutorials that guide you through building complete applications with Wren-CLI. Each tutorial introduces new concepts and builds upon previous knowledge.</p>
<div class="card-grid">
<div class="card">
<h3><a href="http-client.html">Building an HTTP Client</a></h3>
<p>Learn to make HTTP requests, parse JSON responses, and handle errors while building a REST API client.</p>
<div class="card-meta">
<span class="tag">http</span>
<span class="tag">json</span>
</div>
</div>
<div class="card">
<h3><a href="websocket-chat.html">WebSocket Chat Application</a></h3>
<p>Build a real-time chat application using WebSockets with both client and server components.</p>
<div class="card-meta">
<span class="tag">websocket</span>
<span class="tag">fibers</span>
</div>
</div>
<div class="card">
<h3><a href="database-app.html">Database Application</a></h3>
<p>Create a complete CRUD application using SQLite for persistent data storage.</p>
<div class="card-meta">
<span class="tag">sqlite</span>
<span class="tag">io</span>
</div>
</div>
<div class="card">
<h3><a href="template-rendering.html">Template Rendering</a></h3>
<p>Use Jinja templates to generate HTML pages, reports, and configuration files.</p>
<div class="card-meta">
<span class="tag">jinja</span>
<span class="tag">io</span>
</div>
</div>
<div class="card">
<h3><a href="cli-tool.html">Building a CLI Tool</a></h3>
<p>Create a command-line application with argument parsing, user input, and subprocess management.</p>
<div class="card-meta">
<span class="tag">os</span>
<span class="tag">subprocess</span>
</div>
</div>
<div class="card">
<h3><a href="web-server.html">Building a Web Server</a></h3>
<p>Build HTTP servers with routing, sessions, middleware, and REST APIs using the web module.</p>
<div class="card-meta">
<span class="tag">web</span>
<span class="tag">http</span>
</div>
</div>
</div>
<h2>Learning Path</h2>
<p>If you are new to Wren-CLI, we recommend following the tutorials in this order:</p>
<ol>
<li><strong>HTTP Client</strong> - Introduces async operations and JSON handling</li>
<li><strong>Database Application</strong> - Covers data persistence and file I/O</li>
<li><strong>Template Rendering</strong> - Learn the Jinja template system</li>
<li><strong>WebSocket Chat</strong> - Advanced async patterns with fibers</li>
<li><strong>CLI Tool</strong> - Bringing it all together in a real application</li>
<li><strong>Web Server</strong> - Build complete web applications with the web module</li>
</ol>
<h2>Prerequisites</h2>
<p>Before starting the tutorials, you should:</p>
<ul>
<li>Have Wren-CLI <a href="../getting-started/installation.html">installed</a></li>
<li>Understand the <a href="../language/index.html">basic syntax</a></li>
<li>Be familiar with <a href="../language/classes.html">classes</a> and <a href="../language/methods.html">methods</a></li>
</ul>
{% endblock %}

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More