Skip to content

Chapter 18: The Wyn Toolchain

Everything you need to build, test, deploy, and maintain Wyn projects.

Project Setup

bash
wyn new myapp          # Create project
wyn new myapp --web    # Web app with routes, templates, deploy config
wyn new myapp --cli    # CLI tool
wyn new myapp --api    # HTTP service
wyn new mylib --lib python  # Library (targets: wyn, python, node, c)

Every project gets wyn.toml, src/main.wyn, tests/, .gitignore, and README.md.

wyn.toml

The single project manifest:

toml
[project]
name = "myapp"
version = "1.0.0"
entry = "src/main.wyn"

[dependencies]
# http-client = "github.com/wynlang/http-client"

[deploy.prod]
host = "myserver.com"
user = "deploy"
key = "~/.ssh/id_ed25519"
path = "/opt/myapp"
os = "linux"
pre = "systemctl stop myapp"
post = "systemctl start myapp"

Build & Run

bash
wyn run                    # Reads wyn.toml, runs entry
wyn run src/main.wyn       # Run specific file
wyn run -e 'println("hi")' # Eval inline
wyn build .                # Build binary
wyn build . --python       # Build Python library
wyn build . --shared       # Build shared library
wyn cross linux src/main.wyn  # Cross-compile

Testing

bash
wyn test                   # Run project tests
wyn test math              # Run only test files whose path contains "math"
wyn bench src/main.wyn     # Benchmark (10 runs, auto-compares)

Code Quality

bash
wyn check src/main.wyn     # Type-check without compiling
wyn fmt src/                # Format all .wyn files
wyn fmt src/ --check        # Check formatting (for CI)
wyn doc src/main.wyn --html # Generate HTML docs

Deployment

bash
wyn deploy prod            # Cross-compile + SCP + restart
wyn deploy prod --dry-run  # Preview
wyn ssh prod               # SSH into server
wyn logs prod              # Tail service logs

Maintenance

bash
wyn doctor                 # Check setup (gcc, runtime, PATH)
wyn upgrade                # Self-update from GitHub
wyn version                # Show version
wyn wisdom                 # Flight Rules

Multi-File Projects

wyn
// src/utils.wyn
export fn helper() -> string { return "from utils" }

// src/main.wyn
import utils
fn main() -> int {
    println(utils.helper())
    return 0
}

Environment Config

Create .env:

DATABASE_URL=app.db
PORT=8080
SECRET=my-secret

Load in Wyn:

wyn
System.load_env(".env")
var port = System.env("PORT")

Exercises

  1. Create a --web project, add a new route, deploy with --dry-run
  2. Set up CI: wyn fmt . --check && wyn test
  3. Build a Python library and call it from a Python script

Previous: Chapter 17: Web Development | Next: Appendix A: Language Reference

MIT License - v1.19.1