Wren CLI Project

Project Overview

The Wren CLI is a command-line interface and REPL (Read-Eval-Print Loop) for the Wren programming language. It embeds the Wren Virtual Machine (VM) and provides standard IO capabilities (file system, networking, etc.) using libuv.

Key Components:

  • src/cli: Contains the main entry point (main.c) and CLI-specific logic.
  • src/module: Implementations of built-in modules (like io, os, scheduler, timer, net).
  • deps/wren: The core Wren VM source code.
  • deps/libuv: The asynchronous I/O library used for system interactions.

New Features

  • Networking: A full-featured net module supporting TCP Socket and Server.
  • Stderr: io module now includes Stderr class.

Building

The project uses make for Linux/macOS and Visual Studio for Windows.

Linux:

cd projects/make
make

macOS:

cd projects/make.mac
make

Windows: Open projects/vs2017/wren-cli.sln or projects/vs2019/wren-cli.sln in Visual Studio.

Output: The compiled binary is placed in the bin/ directory.

  • Release: bin/wren_cli
  • Debug: bin/wren_cli_d

Running

REPL: Run the binary without arguments to start the interactive shell:

./bin/wren_cli

Run a Script: Pass the path to a Wren script:

./bin/wren_cli path/to/script.wren

Testing

The project uses a Python script to run the test suite.

Run All Tests:

python util/test.py

Run Specific Suite: You can pass a path substring to run a subset of tests:

python util/test.py io
python util/test.py language

Test Structure: Tests are located in the test/ directory. They are written in Wren and use expectation comments (e.g., // expect: ...) which the test runner parses to verify output.

Development Conventions

  • Module Implementation: Built-in modules are often split between C and Wren. The Wren side (.wren files in src/module) uses foreign declarations which are bound to C functions (.c files in src/module).
  • Code Style: Follows the style of the existing C and Wren files.
  • Build System: The Makefiles are generated by premake. If you need to change the build configuration, modify projects/premake/premake5.lua and regenerate the projects (though you can editing Makefiles directly for small local changes).