Files
wren/example/os_demo.wren
T
retoor 04e467e09b feat: add wasm build targets, profile hooks, os_demo example, and restructure manual source
- Add `wasm`, `wasm-clean`, and `install-emscripten` phony targets to Makefile for WebAssembly cross-compilation
- Insert `WREN_PROFILE_ENTER`/`WREN_PROFILE_EXIT` macros in `wren_vm.h` and `wren_vm.c` to support optional runtime profiling via `WREN_PROFILE_ENABLED`
- Create `example/os_demo.wren` demonstrating Platform, Process, and conditional exit usage
- Update `example/regex_demo.wren` to import `Match` and exercise Match object properties, groups, and `matchAll`
- Remove static HTML manual pages (`base64.html`, `dns.html`, `json.html`) and replace with structured `manual_src/` directory containing Jinja2 templates, YAML metadata, and content pages
- Expand `README.md` with build targets table, manual building instructions, source layout, and guide for adding new module documentation
2026-01-26 04:12:14 +00:00

37 lines
1.1 KiB
JavaScript
Vendored

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