Skip to content
Topaz6.0 · Before release
Download

Search documentation

Specification 6.0 · Not released · Tested product 5.21.3

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

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

    Tools

    init

    Creates a Topaz package at the selected root.

    Invocation, options and results

    Link

    topaz init

    Synopsis
    1. topaz init

    Input

    topaz init accepts no positional operands. --root <dir> selects the destination and defaults to the current directory. A supplied directory value must be nonempty.

    The target is native. --target native selects it explicitly. Other target values are rejected before files are written.

    The generated package uses the current language mode. An explicit --language-version must select that mode. It does not request an older scaffold.

    Missing option values, unknown options, repeated options, attached values, program arguments after --, and output-format options are rejected before package creation.

    Options and conflicts

    OptionDefaultContractConflicts
    --root <dir>.

    The explicit source root or package root for this invocation.

    None listed
    --target nativenative

    scaffold a deterministic current-profile native package at --root (default .); refuses to overwrite existing files

    None listed
    --language-version <5.21>5.21

    language version selector

    None listed

    Output channels

    stdout

    stderr

    Exit status

    0

    Both the manifest and entry were written completely.

    1

    Invalid arguments, an unsupported target or language mode, an existing destination file, an unreadable destination, and any directory or file write failure.

    Effects

    The command creates the selected root and its src directory as needed. It creates topaz.toml and src/main.tpz with exclusive file creation.

    Both destination paths are checked before either file is written. An existing manifest or entry is an error even when its contents match the scaffold. Other files in the root are preserved.

    The manifest is written before the entry. A later I/O failure can leave the new manifest and directories behind. A failed scaffold is incomplete and is never reported as successful.

    Initialization uses the installed template and makes no network requests. It does not download the standard library or a toolchain.

    The same installed release, current language mode, and destination basename produce the same scaffold bytes. The package name keeps ASCII letters, digits, underscores, and hyphens from the basename and replaces other characters with underscores. An absent or empty basename selects topaz_app.

    The destination path in the completion message is resolved for the current filesystem. Repeating initialization in an already populated destination fails instead of replacing it.

    The standard-library dependency uses a table as required by dependency-table.1. Initialization creates neither topaz.lock nor a vendor tree. Lock generation is a separate operation.

    Operation

    Link

    Use an empty destination for a new package. Existing files are protected from replacement.

    Option conditions

    Link

    --target applies to emit, build, or init only

    Behavior contract

    Link
    Ruletools-commands-init.rule.behavior

    Command behavior

    Arguments and rejection

    topaz init accepts no positional operands. --root <dir> selects the destination and defaults to the current directory. A supplied directory value must be nonempty.

    The target is native. --target native selects it explicitly. Other target values are rejected before files are written.

    The generated package uses the current language mode. An explicit --language-version must select that mode. It does not request an older scaffold.

    Missing option values, unknown options, repeated options, attached values, program arguments after --, and output-format options are rejected before package creation.

    Output

    Successful creation leaves standard output empty. Standard error reports the package name and resolved destination in one completion line.

    Failures write a human diagnostic to standard error and leave standard output empty. --format json is rejected because initialization has no JSON report.

    The generated manifest has package version 0.1.0, entry src/main.tpz, native build target, deterministic builds enabled, and a std dependency table containing the current language version. The entry is a complete Topaz program that writes Hello from Topaz and returns success.

    Exit status

    Exit code 0 means both the manifest and entry were written completely.

    Exit code 1 covers invalid arguments, an unsupported target or language mode, an existing destination file, an unreadable destination, and any directory or file write failure.

    Filesystem effects

    The command creates the selected root and its src directory as needed. It creates topaz.toml and src/main.tpz with exclusive file creation.

    Both destination paths are checked before either file is written. An existing manifest or entry is an error even when its contents match the scaffold. Other files in the root are preserved.

    The manifest is written before the entry. A later I/O failure can leave the new manifest and directories behind. A failed scaffold is incomplete and is never reported as successful.

    Network access

    Initialization uses the installed template and makes no network requests. It does not download the standard library or a toolchain.

    Reproducibility

    The same installed release, current language mode, and destination basename produce the same scaffold bytes. The package name keeps ASCII letters, digits, underscores, and hyphens from the basename and replaces other characters with underscores. An absent or empty basename selects topaz_app.

    The destination path in the completion message is resolved for the current filesystem. Repeating initialization in an already populated destination fails instead of replacing it.

    Packages and locks

    The standard-library dependency uses a table as required by dependency-table.1. Initialization creates neither topaz.lock nor a vendor tree. Lock generation is a separate operation.

    Why

    Package creation chooses the destination through --root. A positional source path would express a second destination with no distinct role. Exclusive creation protects existing work and makes a successful scaffold immediately usable.

    Source evidence

    The linked public CLI recipe checks the exact displayed argument rejection before the requested operation. It does not execute the successful operation or verify its effects.

    Successful initialization writes a package and is outside the execution allowlist. The linked safe recipe exercises rejection of an extra source operand. The public CLI cannot start in this sandbox, so the administrator runs that recipe in CI.

    Example contract

    Link
    Ruletools-commands-init.rule.invocation

    Example contract

    The invocation topaz init main.tpz --language-version 5.21 is expected to exit with 1.

    The command has no positional source operand. The adapter-supplied fixture operand is deliberately rejected before its operation; this is an arity example, not a successful init session.

    Why

    The package destination is selected by --root. Rejecting a positional file keeps package creation from accepting an unused second destination.

    Source evidence

    Example

    Link

    Argument-rejection example

    Link
    main.tpzArgument-rejection exampleOpen in Playground
    1. function identity<T>(value: T) -> T {
    2. value
    3. }
    target product 5.21.3
    Expected result

    Expected result

    Textual rejection details remain Pending in the reference model. The independent Tools example gate expects exit 1.

    The command has no positional source operand. The adapter-supplied fixture operand is deliberately rejected before its operation; this is an arity example, not a successful init session.

    Source evidence

    Verification scope

    Link

    Observed with Topaz 5.21.3 on 2026-11-06T08:36:29.642Z. This invocation passed; exit 1. 3 assertions were evaluated against the independent expected result. Execution record. This result covers the displayed invocation.

    Related references

    Link

    Compiler selection

    Packages, locks and targets

    Menu

    Download