wscript: overview
A statically typed, Rust-flavoured scripting language; vmlab type-checks scripts at vmlab validate time.
wscript is a statically typed, Rust-flavoured scripting language — think Rust minus the borrow checker, lifetimes, and user generics. vmlab compiles scripts with full type checking at vmlab validate time. Every script that drives a lab starts with use vmlab. Scripts are synchronous; all blocking calls take timeouts and return Result[..., string]. Generate vmlab.wscripti (vmlab wscripti) for LSP support when editing scripts.
§ 1Entry points
rust
// Provision script (provision "x.ws" {}) and `vmlab script x.ws`:
// an Err propagating out fails the provision run (and `vmlab up`)
// Event handler (on "vm.crashed" { run = "x.ws" }):
// failures logged, never fatal
§ 2Examples
§ 2.1A provision script driving a guest
fn main(lab: Lab): wait for the agent, run a command, then click a UI element by screen match.
rust
use vmlab
lab.log
let Ok = lab.vm else lab.log
return
}
match dc.wait_ready Ok => lab.log,
Err =>
}
match dc.exec Ok => lab.log,
Err => lab.log,
}
// Screen-driven step: wait for a UI element, click its center.
match dc.wait_for_image Ok => let mv = dc.mouse_move // bind unused Results
let cl = dc.mouse_click
lab.log
}
Err => lab.log,
}
}