Skip to content

Project Anatomy & wysna.toml

For applications larger than a single script, Wysna utilizes a structured project directory governed by a manifest file named wysna.toml.

To create a new Wysna package, use wysna init:

Terminal window
wysna init my_project
cd my_project

This generates the standard layout:

my_project/
├── wysna.toml # Project manifest & compiler configuration
└── src/
└── main.wysna # Application entry point

The manifest defines package metadata, compilation targets, and dependency links:

[package]
name = "my_project"
version = "0.1.0"
authors = ["Washington Yandún <washo@wysofia.com>"]
entry = "src/main.wysna"
[build]
target = "host-native" # Options: host-native, c99, wasi
opt_level = 2 # Optimization level passed to C backend (0, 1, 2, 3)
debug = true # Preserve source maps and line assertions
[dependencies]
# External Wysna modules or native C libraries

You can organize code across multiple files inside src/. For example, create src/math_utils.wysna:

## src/math_utils.wysna
pub fn square(x: int) -> int {
return x * x
}
pub fn clamp(val: int, min_val: int, max_val: int) -> int {
if val < min_val {
return min_val
}
if val > max_val {
return max_val
}
return val
}

Now import and use it in src/main.wysna using string path imports:

## src/main.wysna
import "math_utils.wysna"
fn main() -> unit {
let result = math_utils.square(8)
print("Square of 8:", result)
let clamped = math_utils.clamp(120, 0, 100)
print("Clamped value:", clamped)
}

Compile the entire project from the root directory:

Terminal window
wysna build

The output binary will be written to build/bin/my_project.