- Language mode
- 6.0
- Product
- Not released
Run a file or package
For a source file, use topaz run main.. For a package, use topaz run - or run topaz run in the package directory. In package mode, topaz. supplies the entry. Use - for registry dependencies.
By default run checks the source, builds a temporary native executable and launches it. It needs the installed code writer and local Rust build tools. Native generation can reject features even after the source passes checking.
Use topaz version - to confirm Language mode: topaz- and topaz help to list installed commands. Use your first program for a small file and the run reference for options.
Use - on run to select the reference interpreter.
Pass arguments and standard input
Define export function main(args: Array<string>, stdin: string) - in the entry module. In topaz run main., args contains one string, "Ada". An invocation with program arguments requires an explicit main.
To try this entry point, add import std. above the function. In its body, write io. and then Ok(0) on the next line. Supply input through a pipe or end standard input after typing it.
The interpreter reads standard input to EOF and passes the text as stdin. A later io. in main returns an empty string. Returning Ok(code) sets the process exit code from 0 through 255. Returning Err(message) writes the message to standard error and exits with code 1.
Emit Rust or build a native executable
Use a development CLI built with native- and its installed writer. Emit with topaz emit main. writes Rust to standard output. Add - with a new directory to write main. there.
On a development installation with the local Rust build tools and runtime inputs, run topaz build main.. Choose a new output directory under an existing parent. On success, build writes out/ or out/. Add - to start the executable after the build. Put program arguments after - as for run.
This build path supports the native target. Programs that use features outside the native generator’s supported subset can still be rejected after checking.
Document package exports
Use topaz doc - to check the package and write exports. and index. for its exports. The manifest selects the export module. See the doc reference for the package and output options.