Skip to content
Topazdocs
6.05.21

Search documentation

Specification 6.0

Use arrow keys to choose a result. Press Enter to open.

Type an API name, diagnostic number, rule, or project topic.

    Download

    Tools

    Running programs with the Topaz 6.0 development CLI

    Run a file or a package, pass input to an explicit entry point and use the native development commands.

    Language mode
    6.0
    Product
    Not released

    Run a file or package

    For a source file, use topaz run main.tpz --language-version 6.0. For a package, use topaz run --root my-package or run topaz run in the package directory. In package mode, topaz.toml supplies the entry. Use --locked 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 --verbose to confirm Language mode: topaz-6.0 and topaz help to list installed commands. Use your first program for a small file and the run reference for options.

    Use --compiler rust on run to select the reference interpreter.

    Pass arguments and standard input

    Define export function main(args: Array<string>, stdin: string) -> Result<int, string> in the entry module. In topaz run main.tpz --language-version 6.0 --compiler rust -- Ada, args contains one string, "Ada". An invocation with program arguments requires an explicit main.

    To try this entry point, add import std.io above the function. In its body, write io.writeLine(stdin) 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.readStdin() 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-dev and its installed writer. Emit with topaz emit main.tpz --target rust writes Rust to standard output. Add --out-dir with a new directory to write main.rs there.

    On a development installation with the local Rust build tools and runtime inputs, run topaz build main.tpz --target native --out-dir out. Choose a new output directory under an existing parent. On success, build writes out/program or out/program.exe. Add --run 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 --root my-package --out-dir api to check the package and write exports.json and index.md for its exports. The manifest selects the export module. See the doc reference for the package and output options.